Submission #711954

# Submission time Handle Problem Language Result Execution time Memory
711954 2023-03-17T19:08:14 Z thimote75 Art Exhibition (JOI18_art) C++14
100 / 100
993 ms 52464 KB
#include <bits/stdc++.h>

using namespace std;

#define num long long
#define ndata vector<num>

struct VBO {
    map<num, num> sv_by_s;

    num _get_e(num size) {
        auto u = sv_by_s.find(size);
        if (u == sv_by_s.end()) return 0;

        num res = (*u).second;
        sv_by_s.erase(size);
        return res;
    }
    void insert (num size, num value) {
        num old = _get_e(size);

        sv_by_s.insert({ size, old + value });
    }
};

int main () {
    int nbArt;
    cin >> nbArt;

    VBO data;
    for (int iA = 0; iA < nbArt; iA ++) {
        num a, b;
        cin >> a >> b;

        data.insert(a, b);
    }

    ndata size;
    ndata value;
    for (auto d : data.sv_by_s) {
        size .push_back(d.first);
        value.push_back(d.second);
    }

    nbArt = size.size();

    num max_v = 0;
    num sum_v = 0;
    num max_a = 0;
    
    for (int iA = 0; iA < nbArt; iA ++) {
        max_v = max(max_v, size[iA] - sum_v);
        num answer = sum_v + value[iA] - size[iA] + max_v;
        max_a = max(max_a, answer);
        
        sum_v += value[iA];
    }

    cout << max_a;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 6 ms 852 KB Output is correct
28 Correct 7 ms 852 KB Output is correct
29 Correct 7 ms 852 KB Output is correct
30 Correct 7 ms 852 KB Output is correct
31 Correct 6 ms 852 KB Output is correct
32 Correct 6 ms 852 KB Output is correct
33 Correct 6 ms 852 KB Output is correct
34 Correct 6 ms 852 KB Output is correct
35 Correct 7 ms 828 KB Output is correct
36 Correct 7 ms 824 KB Output is correct
37 Correct 6 ms 852 KB Output is correct
38 Correct 7 ms 820 KB Output is correct
39 Correct 7 ms 820 KB Output is correct
40 Correct 7 ms 900 KB Output is correct
41 Correct 7 ms 852 KB Output is correct
42 Correct 7 ms 852 KB Output is correct
43 Correct 7 ms 852 KB Output is correct
44 Correct 7 ms 824 KB Output is correct
45 Correct 6 ms 852 KB Output is correct
46 Correct 7 ms 852 KB Output is correct
47 Correct 7 ms 852 KB Output is correct
48 Correct 7 ms 864 KB Output is correct
49 Correct 6 ms 864 KB Output is correct
50 Correct 6 ms 864 KB Output is correct
51 Correct 7 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 304 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 300 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 6 ms 852 KB Output is correct
28 Correct 7 ms 852 KB Output is correct
29 Correct 7 ms 852 KB Output is correct
30 Correct 7 ms 852 KB Output is correct
31 Correct 6 ms 852 KB Output is correct
32 Correct 6 ms 852 KB Output is correct
33 Correct 6 ms 852 KB Output is correct
34 Correct 6 ms 852 KB Output is correct
35 Correct 7 ms 828 KB Output is correct
36 Correct 7 ms 824 KB Output is correct
37 Correct 6 ms 852 KB Output is correct
38 Correct 7 ms 820 KB Output is correct
39 Correct 7 ms 820 KB Output is correct
40 Correct 7 ms 900 KB Output is correct
41 Correct 7 ms 852 KB Output is correct
42 Correct 7 ms 852 KB Output is correct
43 Correct 7 ms 852 KB Output is correct
44 Correct 7 ms 824 KB Output is correct
45 Correct 6 ms 852 KB Output is correct
46 Correct 7 ms 852 KB Output is correct
47 Correct 7 ms 852 KB Output is correct
48 Correct 7 ms 864 KB Output is correct
49 Correct 6 ms 864 KB Output is correct
50 Correct 6 ms 864 KB Output is correct
51 Correct 7 ms 864 KB Output is correct
52 Correct 981 ms 52112 KB Output is correct
53 Correct 941 ms 52352 KB Output is correct
54 Correct 937 ms 52300 KB Output is correct
55 Correct 914 ms 52376 KB Output is correct
56 Correct 945 ms 52364 KB Output is correct
57 Correct 931 ms 52328 KB Output is correct
58 Correct 962 ms 52400 KB Output is correct
59 Correct 958 ms 52220 KB Output is correct
60 Correct 992 ms 52236 KB Output is correct
61 Correct 963 ms 52128 KB Output is correct
62 Correct 945 ms 52244 KB Output is correct
63 Correct 993 ms 52264 KB Output is correct
64 Correct 927 ms 52464 KB Output is correct
65 Correct 977 ms 52232 KB Output is correct
66 Correct 938 ms 52424 KB Output is correct
67 Correct 896 ms 52404 KB Output is correct
68 Correct 932 ms 52204 KB Output is correct