QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#531236#8768. Arrested DevelopmentHanShen_256RE 47ms13260kbC++20596b2024-08-24 19:24:162024-08-24 19:24:16

Judging History

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

  • [2024-08-24 19:24:16]
  • 评测
  • 测评结果:RE
  • 用时:47ms
  • 内存:13260kb
  • [2024-08-24 19:24:16]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int inf = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> dp{0};
    for (int i = 0, a, b; i < n; i ++ ) {
        cin >> a >> b;
        dp.resize(dp.size() + a, inf);
        for (int j = dp.size(); j >= 0; j -- ) {
            dp[j] = min(dp[j] + b, j >= a ? dp[j - a] : inf);
        }
    }
    int ans = inf;
    for (int i = 0; i < dp.size(); i ++ ) {
        ans = min(ans, max(i, dp[i]));
    }
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

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: 3556kb

input:

2
314 1
592 6

output:

7

result:

ok single line: '7'

Test #3:

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

input:

1
1 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1
100000 1

output:

1

result:

ok single line: '1'

Test #5:

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

input:

1
1 100000

output:

1

result:

ok single line: '1'

Test #6:

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

input:

1
100000 100000

output:

100000

result:

ok single line: '100000'

Test #7:

score: 0
Accepted
time: 47ms
memory: 13260kb

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:

855897

result:

ok single line: '855897'

Test #8:

score: -100
Runtime Error

input:

50
17109 75621
51243 72763
67210 97483
57809 9601
66344 79911
91593 38930
51920 44188
82765 20595
87230 78655
78390 14375
20216 46782
64273 61631
82422 38207
38700 26994
58768 59731
90891 94282
11999 82480
10537 43098
60805 6845
99773 94421
77415 93587
20930 48902
41915 46679
47122 15869
80233 45051...

output:


result: