Submission #70847

# Submission time Handle Problem Language Result Execution time Memory
70847 2018-08-23T14:10:50 Z someone_aa Art Exhibition (JOI18_art) C++17
50 / 100
1000 ms 25632 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 500100;
map<ll, ll> sum;
vector<pair<ll, ll> > values;
vector<ll> pref;
ll n, x, y;

ll get_val(int l, int r) {
    ll sum =1LL* pref[r] - pref[l-1];
    ll diff = values[r].first - values[l].first;
    return sum - diff;
}

int main() {
    cin>>n;
    for(int i=0;i<n;i++) {
        cin>>x>>y;
        sum[x] += y;
    }

    values.pb(mp(0LL,0LL));
    pref.pb(0LL);
    for(auto i:sum) {
        values.pb(mp(i.first, i.second));
        pref.pb(pref.back() + i.second);
    }

    ll l = 1LL;
    ll result = get_val(1,1);
    ll max_pref = values[1].first;
    for(ll i=2;i<values.size();i++) {
        max_pref = max(max_pref, values[i].first - pref[i-1]);
        ll curr_val = pref[i] - values[i].first + max_pref;
        result = max(result, curr_val);
    }
    cout<<result;

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i=2;i<values.size();i++) {
                ~^~~~~~~~~~~~~~
art.cpp:32:8: warning: unused variable 'l' [-Wunused-variable]
     ll l = 1LL;
        ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 3 ms 612 KB Output is correct
6 Correct 3 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 3 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 3 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 3 ms 612 KB Output is correct
6 Correct 3 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 3 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 3 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 3 ms 612 KB Output is correct
14 Correct 3 ms 612 KB Output is correct
15 Correct 3 ms 612 KB Output is correct
16 Correct 3 ms 612 KB Output is correct
17 Correct 3 ms 620 KB Output is correct
18 Correct 3 ms 620 KB Output is correct
19 Correct 3 ms 620 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 4 ms 624 KB Output is correct
22 Correct 3 ms 624 KB Output is correct
23 Correct 4 ms 624 KB Output is correct
24 Correct 3 ms 624 KB Output is correct
25 Correct 4 ms 624 KB Output is correct
26 Correct 4 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 3 ms 612 KB Output is correct
6 Correct 3 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 3 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 3 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 3 ms 612 KB Output is correct
14 Correct 3 ms 612 KB Output is correct
15 Correct 3 ms 612 KB Output is correct
16 Correct 3 ms 612 KB Output is correct
17 Correct 3 ms 620 KB Output is correct
18 Correct 3 ms 620 KB Output is correct
19 Correct 3 ms 620 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 4 ms 624 KB Output is correct
22 Correct 3 ms 624 KB Output is correct
23 Correct 4 ms 624 KB Output is correct
24 Correct 3 ms 624 KB Output is correct
25 Correct 4 ms 624 KB Output is correct
26 Correct 4 ms 724 KB Output is correct
27 Correct 13 ms 1132 KB Output is correct
28 Correct 11 ms 1132 KB Output is correct
29 Correct 16 ms 1132 KB Output is correct
30 Correct 10 ms 1132 KB Output is correct
31 Correct 10 ms 1132 KB Output is correct
32 Correct 11 ms 1168 KB Output is correct
33 Correct 13 ms 1168 KB Output is correct
34 Correct 13 ms 1168 KB Output is correct
35 Correct 12 ms 1168 KB Output is correct
36 Correct 12 ms 1168 KB Output is correct
37 Correct 12 ms 1168 KB Output is correct
38 Correct 12 ms 1268 KB Output is correct
39 Correct 12 ms 1268 KB Output is correct
40 Correct 12 ms 1268 KB Output is correct
41 Correct 13 ms 1268 KB Output is correct
42 Correct 12 ms 1268 KB Output is correct
43 Correct 12 ms 1268 KB Output is correct
44 Correct 11 ms 1268 KB Output is correct
45 Correct 14 ms 1268 KB Output is correct
46 Correct 11 ms 1268 KB Output is correct
47 Correct 12 ms 1268 KB Output is correct
48 Correct 12 ms 1268 KB Output is correct
49 Correct 10 ms 1268 KB Output is correct
50 Correct 12 ms 1268 KB Output is correct
51 Correct 12 ms 1268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 476 KB Output is correct
4 Correct 3 ms 612 KB Output is correct
5 Correct 3 ms 612 KB Output is correct
6 Correct 3 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 3 ms 612 KB Output is correct
9 Correct 3 ms 612 KB Output is correct
10 Correct 3 ms 612 KB Output is correct
11 Correct 3 ms 612 KB Output is correct
12 Correct 3 ms 612 KB Output is correct
13 Correct 3 ms 612 KB Output is correct
14 Correct 3 ms 612 KB Output is correct
15 Correct 3 ms 612 KB Output is correct
16 Correct 3 ms 612 KB Output is correct
17 Correct 3 ms 620 KB Output is correct
18 Correct 3 ms 620 KB Output is correct
19 Correct 3 ms 620 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 4 ms 624 KB Output is correct
22 Correct 3 ms 624 KB Output is correct
23 Correct 4 ms 624 KB Output is correct
24 Correct 3 ms 624 KB Output is correct
25 Correct 4 ms 624 KB Output is correct
26 Correct 4 ms 724 KB Output is correct
27 Correct 13 ms 1132 KB Output is correct
28 Correct 11 ms 1132 KB Output is correct
29 Correct 16 ms 1132 KB Output is correct
30 Correct 10 ms 1132 KB Output is correct
31 Correct 10 ms 1132 KB Output is correct
32 Correct 11 ms 1168 KB Output is correct
33 Correct 13 ms 1168 KB Output is correct
34 Correct 13 ms 1168 KB Output is correct
35 Correct 12 ms 1168 KB Output is correct
36 Correct 12 ms 1168 KB Output is correct
37 Correct 12 ms 1168 KB Output is correct
38 Correct 12 ms 1268 KB Output is correct
39 Correct 12 ms 1268 KB Output is correct
40 Correct 12 ms 1268 KB Output is correct
41 Correct 13 ms 1268 KB Output is correct
42 Correct 12 ms 1268 KB Output is correct
43 Correct 12 ms 1268 KB Output is correct
44 Correct 11 ms 1268 KB Output is correct
45 Correct 14 ms 1268 KB Output is correct
46 Correct 11 ms 1268 KB Output is correct
47 Correct 12 ms 1268 KB Output is correct
48 Correct 12 ms 1268 KB Output is correct
49 Correct 10 ms 1268 KB Output is correct
50 Correct 12 ms 1268 KB Output is correct
51 Correct 12 ms 1268 KB Output is correct
52 Execution timed out 1091 ms 25632 KB Time limit exceeded
53 Halted 0 ms 0 KB -