QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#850385#8768. Arrested Developmentanyan26WA 43ms101348kbC++141008b2025-01-10 07:16:292025-01-10 07:16:30

Judging History

你现在查看的是最新测评结果

  • [2025-01-10 07:16:30]
  • 评测
  • 测评结果:WA
  • 用时:43ms
  • 内存:101348kb
  • [2025-01-10 07:16:29]
  • 提交

answer

#include <bits/stdc++.h>
#include <queue>
using namespace std;
struct state{
	int awork;
	int bwork;
	long long taken;
	bool operator < (const state & other) const {
		return max(awork, bwork) > max(other.awork, other.bwork);
	}
};
const int maxsum = 5e6+5;
int main() {
	int n; cin >> n;
	int a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	int dp[n+1][maxsum]; //min B time when A had maxsum time 
	for(int i = 0; i <= n; i++)for(int j = 0; j < maxsum; j++)dp[i][j] = -1;
	for(int i = 0; i < maxsum; i++)dp[0][i] = 0;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < maxsum; j++){
			if(dp[i][j] == -1)continue;
			int atime = j + a[i];
			if(dp[i+1][atime] < 0 || dp[i+1][atime] > dp[i][j])dp[i+1][atime] = dp[i][j];
			if(dp[i+1][j] < 0 || dp[i+1][j] > (dp[i][j]+b[i]))dp[i+1][j] = dp[i][j] + b[i];
		}
	}
	int ret = 0;
	for(int i = 0; i < maxsum; i++){
		if(dp[n][i]==-1)continue;
		ret = min(ret, max(i, dp[n][i]));
	}
	cout << ret << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 43ms
memory: 101348kb

input:

4
100 1
1 90
1 20
1 20

output:

0

result:

wrong answer 1st lines differ - expected: '3', found: '0'