답안 #923892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923892 2024-02-08T04:50:02 Z Webbly Art Exhibition (JOI18_art) C++17
100 / 100
131 ms 25572 KB
// Problem: A. ��� ��������
// Contest: Codeforces - EDLIGHT CAMP IOI #1
// URL: https://codeforces.com/group/3wt9BX8ZwP/contest/500376/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                  Solution
//                    Webbly, 27.01.2023
//
//
//                    Arsen ne katai
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////



#include<bits/stdc++.h>

/**
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <time.h>
*/
//#pragma GCC optimize("O3")
//#pragma GCC optimize("fast-loops")
/**
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC target("avx")
*/
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define flush cout.flush()

using namespace std;

const ll mod = (ll)1e9 + 7, mod3 = 998244353, inf = (ll)2e16, P = 31;

ll rnd(){
    ll x = rand();

    return rand() ^ x;
}

ll binpow (ll a, ll b){
    ll ans = 1;
    while(b){
        if (b & 1){
            ans *= a;

            ans %= mod;
        }

        b >>= 1;
        a *= a;

        a %= mod;
    }
    return ans;
}
ll gcd(ll a, ll b){
    return (b ? gcd(b, a % b) : a);
}
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

struct tr{
    ll four, seven, inc, dec;
};

struct T{
    ll x, y;
};

ll n, m, k, a[500005], b[500005], p[500005];

T q[500005];

ll get(ll l, ll r){
	return p[r] - p[l - 1] - q[r].x + q[l].x;
}

void sarsen(){
    cin >> n;
    
    for (ll i = 1; i <= n; i++){
    	cin >> q[i].x >> q[i].y;
    }
    
    sort (q + 1, q + n + 1, [](T a, T b){
    	return a.x < b.x;
    });
    
    ll ans = -inf, mx = -inf;
    
    for (ll i = 1; i <= n; i++){
    	p[i] = p[i - 1] + q[i].y;
    	
    	mx = max(mx, -p[i - 1] + q[i].x);
    	
    	ans = max(ans, p[i] - q[i].x + mx);
    }
    
    cout << ans;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    //freopen("justforfood.in", "r", stdin);
    //freopen("justforfood.out", "w", stdout);

    ll TT = 1, tests = 1;

    //cin >> TT;

    while(TT--){
        //cout << "Case " << tests << ": ";

        sarsen();

        //tests++;
    }

    return 0;
}
/**

3 9 15 21 27 33 39 45

5 25 35 55 65 85 95


*/

Compilation message

art.cpp: In function 'int main()':
art.cpp:164:16: warning: unused variable 'tests' [-Wunused-variable]
  164 |     ll TT = 1, tests = 1;
      |                ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 2 ms 544 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 528 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 2 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 2 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 2 ms 544 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 528 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 122 ms 12920 KB Output is correct
53 Correct 126 ms 25440 KB Output is correct
54 Correct 127 ms 25568 KB Output is correct
55 Correct 130 ms 25572 KB Output is correct
56 Correct 130 ms 25432 KB Output is correct
57 Correct 126 ms 25428 KB Output is correct
58 Correct 124 ms 25424 KB Output is correct
59 Correct 123 ms 25448 KB Output is correct
60 Correct 126 ms 25564 KB Output is correct
61 Correct 125 ms 25428 KB Output is correct
62 Correct 126 ms 25428 KB Output is correct
63 Correct 123 ms 25448 KB Output is correct
64 Correct 124 ms 25452 KB Output is correct
65 Correct 128 ms 25444 KB Output is correct
66 Correct 125 ms 25444 KB Output is correct
67 Correct 123 ms 25564 KB Output is correct
68 Correct 131 ms 25572 KB Output is correct