QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#453895#8768. Arrested Developmentucup-team173#WA 7ms42668kbC++20762b2024-06-24 14:32:482024-06-24 14:32:48

Judging History

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

  • [2024-06-24 14:32:48]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:42668kb
  • [2024-06-24 14:32:48]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int MAX = 5e6 + 5;

int f[2][MAX];

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    memset(f, 0x3f, sizeof(f));
    f[1][0] = 0;
    for (int i = 0; i < n; i++) {
        memset(f[i & 1], 0x3f, sizeof(f[i & 1]));
        for (int j = 0; j <= tot; j++) {
            f[i & 1][j] = min(f[~i & 1][j] + b[i], f[i & 1][j]);
            f[i & 1][j + a[i]] = min(f[~i & 1][j], f[i & 1][j + a[i]]);
        }         
        tot += a[i];
    }
    int ans = 1e9;
    for (int i = 0; i < tot; i++) {
        ans = min(ans, max(i, f[~n & 1][i]));
    }
    cout << ans << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 42668kb

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 42564kb

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 4ms
memory: 42640kb

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 42560kb

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

score: -100
Wrong Answer
time: 3ms
memory: 42636kb

input:

1
1 100000

output:

100000

result:

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