# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
876597 | 2023-11-22T04:00:42 Z | hasan2006 | Art Exhibition (JOI18_art) | C++17 | 145 ms | 34764 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll a[N] = {}, b[N] , c[N] , d[N] , dp[N]; void solve() { ll q , i , j , m ,n, z ,s = 0 , f, l , r , k , x , y , mn = 1e18 , mx = 0; cin>>n; vector<pair<ll,ll>>v; for(i = 1; i <= n; i++){ cin>>a[i]>>b[i]; v.pb({a[i] , b[i]}); } sort(all(v)); dp[0] = mx = v[0].se; for(i = 1; i < v.size(); i++){ dp[i] = max(v[i].se , dp[i - 1] - (v[i].fi - v[i - 1].fi) + v[i].se); mx = max(mx , dp[i]); } cout<<mx; } int main(){ TL; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4560 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4564 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 2 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4560 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4564 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 2 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4696 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4568 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 1 ms | 4444 KB | Output is correct |
26 | Correct | 1 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4560 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4564 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 2 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4696 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4568 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 1 ms | 4444 KB | Output is correct |
26 | Correct | 1 ms | 4444 KB | Output is correct |
27 | Correct | 2 ms | 4700 KB | Output is correct |
28 | Correct | 2 ms | 4700 KB | Output is correct |
29 | Correct | 2 ms | 4700 KB | Output is correct |
30 | Correct | 2 ms | 4700 KB | Output is correct |
31 | Correct | 2 ms | 4828 KB | Output is correct |
32 | Correct | 2 ms | 4700 KB | Output is correct |
33 | Correct | 2 ms | 4700 KB | Output is correct |
34 | Correct | 2 ms | 4700 KB | Output is correct |
35 | Correct | 2 ms | 4700 KB | Output is correct |
36 | Correct | 2 ms | 4700 KB | Output is correct |
37 | Correct | 2 ms | 4704 KB | Output is correct |
38 | Correct | 2 ms | 4700 KB | Output is correct |
39 | Correct | 2 ms | 4700 KB | Output is correct |
40 | Correct | 2 ms | 4700 KB | Output is correct |
41 | Correct | 2 ms | 4700 KB | Output is correct |
42 | Correct | 2 ms | 4696 KB | Output is correct |
43 | Correct | 3 ms | 4696 KB | Output is correct |
44 | Correct | 2 ms | 4700 KB | Output is correct |
45 | Correct | 2 ms | 4700 KB | Output is correct |
46 | Correct | 2 ms | 4796 KB | Output is correct |
47 | Correct | 2 ms | 4700 KB | Output is correct |
48 | Correct | 2 ms | 4700 KB | Output is correct |
49 | Correct | 2 ms | 4700 KB | Output is correct |
50 | Correct | 2 ms | 4700 KB | Output is correct |
51 | Correct | 2 ms | 4700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4560 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4564 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 2 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4696 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4568 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 1 ms | 4444 KB | Output is correct |
26 | Correct | 1 ms | 4444 KB | Output is correct |
27 | Correct | 2 ms | 4700 KB | Output is correct |
28 | Correct | 2 ms | 4700 KB | Output is correct |
29 | Correct | 2 ms | 4700 KB | Output is correct |
30 | Correct | 2 ms | 4700 KB | Output is correct |
31 | Correct | 2 ms | 4828 KB | Output is correct |
32 | Correct | 2 ms | 4700 KB | Output is correct |
33 | Correct | 2 ms | 4700 KB | Output is correct |
34 | Correct | 2 ms | 4700 KB | Output is correct |
35 | Correct | 2 ms | 4700 KB | Output is correct |
36 | Correct | 2 ms | 4700 KB | Output is correct |
37 | Correct | 2 ms | 4704 KB | Output is correct |
38 | Correct | 2 ms | 4700 KB | Output is correct |
39 | Correct | 2 ms | 4700 KB | Output is correct |
40 | Correct | 2 ms | 4700 KB | Output is correct |
41 | Correct | 2 ms | 4700 KB | Output is correct |
42 | Correct | 2 ms | 4696 KB | Output is correct |
43 | Correct | 3 ms | 4696 KB | Output is correct |
44 | Correct | 2 ms | 4700 KB | Output is correct |
45 | Correct | 2 ms | 4700 KB | Output is correct |
46 | Correct | 2 ms | 4796 KB | Output is correct |
47 | Correct | 2 ms | 4700 KB | Output is correct |
48 | Correct | 2 ms | 4700 KB | Output is correct |
49 | Correct | 2 ms | 4700 KB | Output is correct |
50 | Correct | 2 ms | 4700 KB | Output is correct |
51 | Correct | 2 ms | 4700 KB | Output is correct |
52 | Correct | 143 ms | 34308 KB | Output is correct |
53 | Correct | 136 ms | 34764 KB | Output is correct |
54 | Correct | 137 ms | 34224 KB | Output is correct |
55 | Correct | 132 ms | 34404 KB | Output is correct |
56 | Correct | 135 ms | 34236 KB | Output is correct |
57 | Correct | 133 ms | 34368 KB | Output is correct |
58 | Correct | 131 ms | 34360 KB | Output is correct |
59 | Correct | 134 ms | 34672 KB | Output is correct |
60 | Correct | 132 ms | 34228 KB | Output is correct |
61 | Correct | 133 ms | 34236 KB | Output is correct |
62 | Correct | 130 ms | 34744 KB | Output is correct |
63 | Correct | 132 ms | 34284 KB | Output is correct |
64 | Correct | 132 ms | 34440 KB | Output is correct |
65 | Correct | 132 ms | 34260 KB | Output is correct |
66 | Correct | 136 ms | 34656 KB | Output is correct |
67 | Correct | 145 ms | 34332 KB | Output is correct |
68 | Correct | 134 ms | 34212 KB | Output is correct |