Submission #117941

# Submission time Handle Problem Language Result Execution time Memory
117941 2019-06-17T13:31:34 Z JohnTitor Art Exhibition (JOI18_art) C++11
100 / 100
192 ms 21036 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "Art"
int n;
class art{
public:
    ll a, b;
    void input(){
        read(a);
        read(b);
    }
};
vector <art> v;
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    v.resize(n);
    for(auto &x: v) x.input();
    sort(v.begin(), v.end(), [](art A, art B){
        return A.a<B.a;
    });
    ll m=-1e18;
    ll ans=-1e18;
    ll sum=0;
    ///start from i to j
    ///(sum[j]-sum[i-1])-(a[j]-a[i])
    ///(sum[j]-a[j])+(a[i]-sum[i-1])
    for(auto x: v){
        ans=max(ans, (sum+x.b)-x.a+m);
        ans=max(ans, x.b);
        m=max(m, x.a-sum);
        sum+=x.b;
    }
    writeln(ans);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 544 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 4 ms 512 KB Output is correct
35 Correct 4 ms 512 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 4 ms 512 KB Output is correct
38 Correct 3 ms 512 KB Output is correct
39 Correct 3 ms 576 KB Output is correct
40 Correct 3 ms 512 KB Output is correct
41 Correct 4 ms 508 KB Output is correct
42 Correct 4 ms 512 KB Output is correct
43 Correct 4 ms 512 KB Output is correct
44 Correct 4 ms 512 KB Output is correct
45 Correct 4 ms 512 KB Output is correct
46 Correct 4 ms 512 KB Output is correct
47 Correct 4 ms 512 KB Output is correct
48 Correct 4 ms 512 KB Output is correct
49 Correct 4 ms 512 KB Output is correct
50 Correct 4 ms 512 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 256 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 256 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 544 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 3 ms 512 KB Output is correct
34 Correct 4 ms 512 KB Output is correct
35 Correct 4 ms 512 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 4 ms 512 KB Output is correct
38 Correct 3 ms 512 KB Output is correct
39 Correct 3 ms 576 KB Output is correct
40 Correct 3 ms 512 KB Output is correct
41 Correct 4 ms 508 KB Output is correct
42 Correct 4 ms 512 KB Output is correct
43 Correct 4 ms 512 KB Output is correct
44 Correct 4 ms 512 KB Output is correct
45 Correct 4 ms 512 KB Output is correct
46 Correct 4 ms 512 KB Output is correct
47 Correct 4 ms 512 KB Output is correct
48 Correct 4 ms 512 KB Output is correct
49 Correct 4 ms 512 KB Output is correct
50 Correct 4 ms 512 KB Output is correct
51 Correct 3 ms 512 KB Output is correct
52 Correct 151 ms 20840 KB Output is correct
53 Correct 149 ms 20960 KB Output is correct
54 Correct 152 ms 20856 KB Output is correct
55 Correct 186 ms 20984 KB Output is correct
56 Correct 156 ms 20856 KB Output is correct
57 Correct 162 ms 20848 KB Output is correct
58 Correct 158 ms 20988 KB Output is correct
59 Correct 160 ms 20856 KB Output is correct
60 Correct 157 ms 20800 KB Output is correct
61 Correct 164 ms 20856 KB Output is correct
62 Correct 181 ms 21036 KB Output is correct
63 Correct 156 ms 20984 KB Output is correct
64 Correct 155 ms 20960 KB Output is correct
65 Correct 161 ms 20856 KB Output is correct
66 Correct 192 ms 20972 KB Output is correct
67 Correct 154 ms 20872 KB Output is correct
68 Correct 150 ms 20856 KB Output is correct