Submission #1049765

# Submission time Handle Problem Language Result Execution time Memory
1049765 2024-08-09T04:49:45 Z vjudge1 Art Exhibition (JOI18_art) C++17
50 / 100
1000 ms 19896 KB
#include <bits/stdc++.h>

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")

using namespace std;

#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define vc vector
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define int ll

const int N = 5e5 + 5;
const int M = 5e5 + 5;
const int mod = 1e9 + 7;
const int block = 500;

int n;
ll a[N], b[N], pref[N];

void solve() {
	cin >> n;
    vc <pair<ll,ll>> save;
    for ( int i = 1; i <= n; i++ ) {
        cin >> a[i] >> b[i];
        save.pb(mp(a[i],b[i]));
    }
    sort(all(save));
    for ( int i = 1; i <= n; i++ ) {
        pref[i] = pref[i-1] + save[i-1].se;
    }
    ll ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= i; j++ ) {
            ans = max(ans,(pref[i]-pref[j-1])-(save[i-1].fi-save[j-1].fi));
        }
    }
    cout << ans;
}

signed main() {
	speed;
	int tt;
	//cin >> tt;
    tt = 1;
	while ( tt-- ) {
		solve();
		cout << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4440 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 0 ms 4444 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 0 ms 4444 KB Output is correct
11 Correct 0 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4440 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 0 ms 4444 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 0 ms 4444 KB Output is correct
11 Correct 0 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 0 ms 4444 KB Output is correct
16 Correct 0 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 4444 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 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4440 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 0 ms 4444 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 0 ms 4444 KB Output is correct
11 Correct 0 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 0 ms 4444 KB Output is correct
16 Correct 0 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 4444 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 34 ms 4696 KB Output is correct
28 Correct 33 ms 4700 KB Output is correct
29 Correct 33 ms 4700 KB Output is correct
30 Correct 33 ms 4700 KB Output is correct
31 Correct 33 ms 4700 KB Output is correct
32 Correct 33 ms 4700 KB Output is correct
33 Correct 34 ms 4952 KB Output is correct
34 Correct 33 ms 4700 KB Output is correct
35 Correct 34 ms 4700 KB Output is correct
36 Correct 34 ms 4828 KB Output is correct
37 Correct 35 ms 4700 KB Output is correct
38 Correct 33 ms 4700 KB Output is correct
39 Correct 42 ms 4700 KB Output is correct
40 Correct 34 ms 4696 KB Output is correct
41 Correct 40 ms 4700 KB Output is correct
42 Correct 34 ms 4696 KB Output is correct
43 Correct 34 ms 4796 KB Output is correct
44 Correct 34 ms 4700 KB Output is correct
45 Correct 33 ms 4696 KB Output is correct
46 Correct 33 ms 4700 KB Output is correct
47 Correct 33 ms 4700 KB Output is correct
48 Correct 33 ms 4700 KB Output is correct
49 Correct 35 ms 4696 KB Output is correct
50 Correct 34 ms 4700 KB Output is correct
51 Correct 33 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 0 ms 4440 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 0 ms 4444 KB Output is correct
7 Correct 0 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 0 ms 4444 KB Output is correct
11 Correct 0 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 0 ms 4444 KB Output is correct
16 Correct 0 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 4444 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 34 ms 4696 KB Output is correct
28 Correct 33 ms 4700 KB Output is correct
29 Correct 33 ms 4700 KB Output is correct
30 Correct 33 ms 4700 KB Output is correct
31 Correct 33 ms 4700 KB Output is correct
32 Correct 33 ms 4700 KB Output is correct
33 Correct 34 ms 4952 KB Output is correct
34 Correct 33 ms 4700 KB Output is correct
35 Correct 34 ms 4700 KB Output is correct
36 Correct 34 ms 4828 KB Output is correct
37 Correct 35 ms 4700 KB Output is correct
38 Correct 33 ms 4700 KB Output is correct
39 Correct 42 ms 4700 KB Output is correct
40 Correct 34 ms 4696 KB Output is correct
41 Correct 40 ms 4700 KB Output is correct
42 Correct 34 ms 4696 KB Output is correct
43 Correct 34 ms 4796 KB Output is correct
44 Correct 34 ms 4700 KB Output is correct
45 Correct 33 ms 4696 KB Output is correct
46 Correct 33 ms 4700 KB Output is correct
47 Correct 33 ms 4700 KB Output is correct
48 Correct 33 ms 4700 KB Output is correct
49 Correct 35 ms 4696 KB Output is correct
50 Correct 34 ms 4700 KB Output is correct
51 Correct 33 ms 4700 KB Output is correct
52 Execution timed out 1070 ms 19896 KB Time limit exceeded
53 Halted 0 ms 0 KB -