Submission #577881

# Submission time Handle Problem Language Result Execution time Memory
577881 2022-06-15T11:05:54 Z Trisanu_Das Art Exhibition (JOI18_art) C++17
100 / 100
570 ms 28620 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<array<long, 2>> v(n);
    for (auto &[a, b] : v) cin >> a >> b;
    sort(v.begin(), v.end());
    vector<long> pref(n + 1, 0);
    for (int i = 0; i < n; i++)
        pref[i + 1] = pref[i] + v[i][1];
    vector diff(pref.begin() + 1, pref.end());
    for (int i = 0; i < n; i++)
        diff[i] -= v[i][0];
    long res = 0;
    long cur = LONG_MIN / 2;
    for (int i = n - 1; i >= 0; i--)
    {
        cur = max(cur, diff[i]);
        res = max(res, cur + v[i][0] - pref[i]);
    }
    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 468 KB Output is correct
30 Correct 6 ms 468 KB Output is correct
31 Correct 6 ms 468 KB Output is correct
32 Correct 6 ms 468 KB Output is correct
33 Correct 7 ms 468 KB Output is correct
34 Correct 7 ms 468 KB Output is correct
35 Correct 6 ms 560 KB Output is correct
36 Correct 7 ms 564 KB Output is correct
37 Correct 9 ms 468 KB Output is correct
38 Correct 6 ms 564 KB Output is correct
39 Correct 6 ms 468 KB Output is correct
40 Correct 7 ms 468 KB Output is correct
41 Correct 6 ms 564 KB Output is correct
42 Correct 6 ms 504 KB Output is correct
43 Correct 6 ms 484 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 6 ms 504 KB Output is correct
47 Correct 6 ms 564 KB Output is correct
48 Correct 8 ms 504 KB Output is correct
49 Correct 6 ms 468 KB Output is correct
50 Correct 6 ms 468 KB Output is correct
51 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 300 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 308 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 6 ms 468 KB Output is correct
28 Correct 6 ms 504 KB Output is correct
29 Correct 6 ms 468 KB Output is correct
30 Correct 6 ms 468 KB Output is correct
31 Correct 6 ms 468 KB Output is correct
32 Correct 6 ms 468 KB Output is correct
33 Correct 7 ms 468 KB Output is correct
34 Correct 7 ms 468 KB Output is correct
35 Correct 6 ms 560 KB Output is correct
36 Correct 7 ms 564 KB Output is correct
37 Correct 9 ms 468 KB Output is correct
38 Correct 6 ms 564 KB Output is correct
39 Correct 6 ms 468 KB Output is correct
40 Correct 7 ms 468 KB Output is correct
41 Correct 6 ms 564 KB Output is correct
42 Correct 6 ms 504 KB Output is correct
43 Correct 6 ms 484 KB Output is correct
44 Correct 6 ms 468 KB Output is correct
45 Correct 6 ms 468 KB Output is correct
46 Correct 6 ms 504 KB Output is correct
47 Correct 6 ms 564 KB Output is correct
48 Correct 8 ms 504 KB Output is correct
49 Correct 6 ms 468 KB Output is correct
50 Correct 6 ms 468 KB Output is correct
51 Correct 6 ms 468 KB Output is correct
52 Correct 540 ms 28520 KB Output is correct
53 Correct 538 ms 28580 KB Output is correct
54 Correct 531 ms 28584 KB Output is correct
55 Correct 543 ms 28564 KB Output is correct
56 Correct 545 ms 28588 KB Output is correct
57 Correct 547 ms 28576 KB Output is correct
58 Correct 538 ms 28620 KB Output is correct
59 Correct 530 ms 28592 KB Output is correct
60 Correct 530 ms 28620 KB Output is correct
61 Correct 525 ms 28476 KB Output is correct
62 Correct 521 ms 28596 KB Output is correct
63 Correct 536 ms 28620 KB Output is correct
64 Correct 533 ms 28584 KB Output is correct
65 Correct 539 ms 28576 KB Output is correct
66 Correct 570 ms 28620 KB Output is correct
67 Correct 550 ms 28584 KB Output is correct
68 Correct 536 ms 28592 KB Output is correct