QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#959350#8768. Arrested DevelopmentbaishixWA 232ms496860kbC++141.1kb2025-03-31 18:19:362025-03-31 18:19:56

Judging History

This is the latest submission verdict.

  • [2025-03-31 18:19:56]
  • Judged
  • Verdict: WA
  • Time: 232ms
  • Memory: 496860kb
  • [2025-03-31 18:19:36]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
const int M = 1e9 + 7;
void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1);
    int max_state = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        max_state += a[i];
    }
    vector<vector<int>> f(n + 1, vector<int>(max_state + 1, M));
    f[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= max_state; j++) {
            if (j + a[i] <= max_state) {
                f[i][j + a[i]] = min(f[i][j + a[i]], max(f[i - 1][j], j + a[i]));
            }
            f[i][j] = min(f[i][j], max(f[i - 1][j], f[i - 1][j] + b[i]));
        }
    }
    int ans = M;
    for (int j = 0; j <= max_state; j++) {
        if (f[n][j] != M) {
            ans = min(ans, f[n][j]);
        }
    }
    cout << ans << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int tt = 1;
    while (tt--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3712kb

input:

4
100 1
1 90
1 20
1 20

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

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

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1
1 100000

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 1ms
memory: 4352kb

input:

1
100000 100000

output:

100000

result:

ok single line: '100000'

Test #7:

score: -100
Wrong Answer
time: 232ms
memory: 496860kb

input:

50
78681 95291
22639 1538
12119 52253
50430 63757
66133 92826
61048 40069
33506 30382
96049 50134
42895 62735
86943 16955
9667 61843
49647 9320
29082 16909
69601 68436
19892 34306
29822 79462
73262 14568
1693 35040
89757 61888
56993 48750
89611 77773
54159 21067
32520 41091
52501 92770
36530 17589
5...

output:

890495

result:

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