Submission #699279

# Submission time Handle Problem Language Result Execution time Memory
699279 2023-02-16T11:45:56 Z Mizo_Compiler Art Exhibition (JOI18_art) C++14
100 / 100
605 ms 40156 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define MOEZ ios_base::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define F first
#define S second
#define pb push_back
#define all(v) v.begin() , v.end()
#define eb emplace_back
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define mem(d , x) memset(d , x , sizeof(d));
#define sz(x) (int)x.size()
//const int N = 2e5+5;
//const int M = 1e9+7;
//const ll inf = 1e17;
//const ld eps = 1e-6;
#define int long long
int n , s = 0;
//multiset<pair<int , int>>m;
signed main(){
    MOEZ
    cin >> n;
    map<int , int>mp;
    for(int i = 0; i < n;i++){
        int a , b;
        cin >> a >> b;
        mp[a] += b;
    }
    vector<pair<int , int>>v;
    int i = 0;
    for(auto x:mp){
        v.pb(x);
        if(i){
            v[i].S += v[i-1].S;
        }
        i++;
    }
    int ans = v[0].S, l = 0 , x = 0;
    s = ans;
    for(int r = 1;r < sz(v);r++){
        s = (v[r].S-x)-(v[r].F-v[l].F);
        ans = max(ans , s);
        if(v[r].S-v[r-1].S >= s){
            ans = max(ans , v[r].S-v[r-1].S);
            l = r;
            x = v[r-1].S;
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 220 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 264 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 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 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 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 256 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 220 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 264 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 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 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 724 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 772 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 3 ms 852 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 772 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 3 ms 772 KB Output is correct
36 Correct 3 ms 724 KB Output is correct
37 Correct 3 ms 772 KB Output is correct
38 Correct 3 ms 852 KB Output is correct
39 Correct 3 ms 772 KB Output is correct
40 Correct 3 ms 852 KB Output is correct
41 Correct 5 ms 772 KB Output is correct
42 Correct 3 ms 852 KB Output is correct
43 Correct 3 ms 772 KB Output is correct
44 Correct 3 ms 772 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 3 ms 852 KB Output is correct
47 Correct 3 ms 772 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 3 ms 852 KB Output is correct
50 Correct 3 ms 852 KB Output is correct
51 Correct 4 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 216 KB Output is correct
11 Correct 0 ms 220 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 264 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 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 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 3 ms 724 KB Output is correct
28 Correct 3 ms 724 KB Output is correct
29 Correct 3 ms 772 KB Output is correct
30 Correct 3 ms 852 KB Output is correct
31 Correct 3 ms 852 KB Output is correct
32 Correct 3 ms 724 KB Output is correct
33 Correct 3 ms 772 KB Output is correct
34 Correct 3 ms 772 KB Output is correct
35 Correct 3 ms 772 KB Output is correct
36 Correct 3 ms 724 KB Output is correct
37 Correct 3 ms 772 KB Output is correct
38 Correct 3 ms 852 KB Output is correct
39 Correct 3 ms 772 KB Output is correct
40 Correct 3 ms 852 KB Output is correct
41 Correct 5 ms 772 KB Output is correct
42 Correct 3 ms 852 KB Output is correct
43 Correct 3 ms 772 KB Output is correct
44 Correct 3 ms 772 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 3 ms 852 KB Output is correct
47 Correct 3 ms 772 KB Output is correct
48 Correct 3 ms 724 KB Output is correct
49 Correct 3 ms 852 KB Output is correct
50 Correct 3 ms 852 KB Output is correct
51 Correct 4 ms 852 KB Output is correct
52 Correct 605 ms 40004 KB Output is correct
53 Correct 577 ms 39900 KB Output is correct
54 Correct 551 ms 39960 KB Output is correct
55 Correct 586 ms 39856 KB Output is correct
56 Correct 583 ms 39976 KB Output is correct
57 Correct 552 ms 39880 KB Output is correct
58 Correct 550 ms 39952 KB Output is correct
59 Correct 556 ms 39868 KB Output is correct
60 Correct 585 ms 39964 KB Output is correct
61 Correct 586 ms 39896 KB Output is correct
62 Correct 586 ms 39972 KB Output is correct
63 Correct 551 ms 39860 KB Output is correct
64 Correct 553 ms 39908 KB Output is correct
65 Correct 557 ms 40156 KB Output is correct
66 Correct 558 ms 39876 KB Output is correct
67 Correct 559 ms 39852 KB Output is correct
68 Correct 585 ms 39864 KB Output is correct