QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#850385 | #8768. Arrested Development | anyan26 | WA | 43ms | 101348kb | C++14 | 1008b | 2025-01-10 07:16:29 | 2025-01-10 07:16:30 |
Judging History
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'