Submission #414415

# Submission time Handle Problem Language Result Execution time Memory
414415 2021-05-30T12:09:24 Z illyakr Art Exhibition (JOI18_art) C++14
100 / 100
910 ms 52172 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n;
pair<int, int> a[501010];
multiset<pair<int, int> > now;
int ans = -8010101010101010101;
int32_t main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i].first >> a[i].second;
    sort(a + 1, a + 1 + n, [](pair<int, int> q, pair<int, int> w) {
         return q.first < w.first;
    });
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += a[i].second;
        now.insert({-(sum - a[i].first), i});
    }
    int er = 0;
    for (int i = 1; i <= n; i++) {
        while (true) {
//            cout << now.size() << " " << i << " << " << endl;
            auto f = *now.begin();
            now.erase(now.begin());
//            cout << f.first << " " << f.second << "   " << i << "  !!!" << endl;
            if (f.second < i)continue;
            ans = max(ans, ((-f.first) - er) + a[i].first);
            now.insert(f);
            break;
        }
        er += a[i].second;
    }
    cout << ans;
}
/**
15
1543361732 260774320
2089759661 257198921
1555665663 389548466
4133306295 296394520
2596448427 301103944
1701413087 274491541
2347488426 912791996
2133012079 444074242
2659886224 656957044
1345396764 259870638
2671164286 233246973
2791812672 585862344
2996614635 91065315
971304780 488995617
1523452673 988137562

6
4 1
1 5
10 3
9 1
4 2
5 3

3
2 3
11 2
4 5
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 8 ms 796 KB Output is correct
28 Correct 8 ms 708 KB Output is correct
29 Correct 8 ms 716 KB Output is correct
30 Correct 8 ms 756 KB Output is correct
31 Correct 10 ms 716 KB Output is correct
32 Correct 9 ms 752 KB Output is correct
33 Correct 9 ms 716 KB Output is correct
34 Correct 8 ms 716 KB Output is correct
35 Correct 10 ms 732 KB Output is correct
36 Correct 8 ms 728 KB Output is correct
37 Correct 9 ms 712 KB Output is correct
38 Correct 8 ms 748 KB Output is correct
39 Correct 9 ms 704 KB Output is correct
40 Correct 9 ms 708 KB Output is correct
41 Correct 9 ms 716 KB Output is correct
42 Correct 8 ms 716 KB Output is correct
43 Correct 7 ms 716 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 776 KB Output is correct
46 Correct 8 ms 720 KB Output is correct
47 Correct 7 ms 720 KB Output is correct
48 Correct 7 ms 720 KB Output is correct
49 Correct 8 ms 720 KB Output is correct
50 Correct 8 ms 716 KB Output is correct
51 Correct 9 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 204 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 2 ms 304 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 2 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 300 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 1 ms 300 KB Output is correct
24 Correct 2 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 8 ms 796 KB Output is correct
28 Correct 8 ms 708 KB Output is correct
29 Correct 8 ms 716 KB Output is correct
30 Correct 8 ms 756 KB Output is correct
31 Correct 10 ms 716 KB Output is correct
32 Correct 9 ms 752 KB Output is correct
33 Correct 9 ms 716 KB Output is correct
34 Correct 8 ms 716 KB Output is correct
35 Correct 10 ms 732 KB Output is correct
36 Correct 8 ms 728 KB Output is correct
37 Correct 9 ms 712 KB Output is correct
38 Correct 8 ms 748 KB Output is correct
39 Correct 9 ms 704 KB Output is correct
40 Correct 9 ms 708 KB Output is correct
41 Correct 9 ms 716 KB Output is correct
42 Correct 8 ms 716 KB Output is correct
43 Correct 7 ms 716 KB Output is correct
44 Correct 9 ms 716 KB Output is correct
45 Correct 8 ms 776 KB Output is correct
46 Correct 8 ms 720 KB Output is correct
47 Correct 7 ms 720 KB Output is correct
48 Correct 7 ms 720 KB Output is correct
49 Correct 8 ms 720 KB Output is correct
50 Correct 8 ms 716 KB Output is correct
51 Correct 9 ms 716 KB Output is correct
52 Correct 739 ms 51924 KB Output is correct
53 Correct 760 ms 51972 KB Output is correct
54 Correct 779 ms 52008 KB Output is correct
55 Correct 755 ms 52052 KB Output is correct
56 Correct 795 ms 52036 KB Output is correct
57 Correct 782 ms 52004 KB Output is correct
58 Correct 778 ms 52092 KB Output is correct
59 Correct 735 ms 52068 KB Output is correct
60 Correct 740 ms 52172 KB Output is correct
61 Correct 758 ms 51972 KB Output is correct
62 Correct 708 ms 51932 KB Output is correct
63 Correct 803 ms 52148 KB Output is correct
64 Correct 723 ms 52072 KB Output is correct
65 Correct 692 ms 51972 KB Output is correct
66 Correct 704 ms 52044 KB Output is correct
67 Correct 737 ms 52044 KB Output is correct
68 Correct 910 ms 52164 KB Output is correct