本地编译器能过 (样例也过了) , luogu上报错 ,求帮忙
查看原帖
本地编译器能过 (样例也过了) , luogu上报错 ,求帮忙
1098953
M_Jun楼主2024/7/15 16:10

源代码 :

#include <iostream> 
#include <cstdio> 
#include <cmath> 
#include <algorithm>
using namespace std ;
#define int long long 

int t , m ;

int time [105] , value [105] ;
int dp [105] [1005] ;

int dfs (int i , int t){
	if(dp [i] [t]){
		return dp [i] [t] ;
	}
	if(i == m) {
		return 0 ;
	}
	if(t >= time [i]){
		dp [i] [t] = max (dfs (i + 1 , t - time [i]) + value [i] , dfs (i + 1 , t)) ;
	}else {
		dp [i] [t] = dfs (i+1, t) ;
	}
	
	return dp [i] [t] ;
}

signed main ( ) {
	cin >> t >> m ;
	for(int i = 0 ; i < m ; i ++) {
		cin >> time [i] >> value [i] ;
	}
	
	cout << dfs (0 , t) << endl ; 
	
	return 0 ;
}	

题目链接 报错信息


恳求 DA LAO 帮 蒟蒻 分析一下

2024/7/15 16:10
加载中...