Submission #945647

# Submission time Handle Problem Language Result Execution time Memory
945647 2024-03-14T05:54:28 Z vjudge1 Art Exhibition (JOI18_art) C++17
50 / 100
48 ms 27984 KB
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
#define ll long long
#define int long long
#define all(v) v.begin(), v.end()
#define nl '\n'
#define pb push_back
#define sz(s) (int)(s).size()
#define f first
#define s second
using namespace std;
const ll N = 2e5 + 50, MX = 5e18;
ll n;
ll a[N], b[N];
ll fst(){
    cin >> n;
    pair <int, int> p[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        p[i].f = a[i] , p[i].s = b[i];
    }
    sort(p + 1, p + 1 + n);
    ll ans = 0;
    ll pr[n+1];
    pr[0]=0;
    pr[1] = p[1].s;
    for(int i = 2; i <= n; i++){
        pr[i] = pr[i-1]+p[i].s;
    }
    for(int l = 1; l <= n; l++){
        for(int r = l; r <= n; r++){
            ans = max((pr[r] - pr[l-1]) - (p[r].f - p[l].f), ans);
            //cout << r << " " << l << " " << p[r].f << " " <<  p[l].f << " " << pr[r] - pr[l-1] << nl;
        }
    }
    return ans;
}
void solve(){
    cout << fst() << nl;
}
signed main(){
    //freopen("lca.in", "r", stdin);
    //freopen("lca.out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll ql=1;
    //cin >> ql;
    //tst++;
    while(ql--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2484 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2484 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2484 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 14 ms 2648 KB Output is correct
28 Correct 14 ms 2652 KB Output is correct
29 Correct 14 ms 2708 KB Output is correct
30 Correct 14 ms 2652 KB Output is correct
31 Correct 18 ms 2796 KB Output is correct
32 Correct 14 ms 2652 KB Output is correct
33 Correct 14 ms 2652 KB Output is correct
34 Correct 14 ms 2804 KB Output is correct
35 Correct 14 ms 2652 KB Output is correct
36 Correct 15 ms 2652 KB Output is correct
37 Correct 14 ms 2712 KB Output is correct
38 Correct 14 ms 2652 KB Output is correct
39 Correct 14 ms 2796 KB Output is correct
40 Correct 14 ms 2648 KB Output is correct
41 Correct 16 ms 3120 KB Output is correct
42 Correct 14 ms 2652 KB Output is correct
43 Correct 14 ms 2652 KB Output is correct
44 Correct 14 ms 2652 KB Output is correct
45 Correct 14 ms 2648 KB Output is correct
46 Correct 15 ms 2652 KB Output is correct
47 Correct 14 ms 2652 KB Output is correct
48 Correct 14 ms 2788 KB Output is correct
49 Correct 14 ms 2652 KB Output is correct
50 Correct 14 ms 2652 KB Output is correct
51 Correct 14 ms 2800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2484 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 14 ms 2648 KB Output is correct
28 Correct 14 ms 2652 KB Output is correct
29 Correct 14 ms 2708 KB Output is correct
30 Correct 14 ms 2652 KB Output is correct
31 Correct 18 ms 2796 KB Output is correct
32 Correct 14 ms 2652 KB Output is correct
33 Correct 14 ms 2652 KB Output is correct
34 Correct 14 ms 2804 KB Output is correct
35 Correct 14 ms 2652 KB Output is correct
36 Correct 15 ms 2652 KB Output is correct
37 Correct 14 ms 2712 KB Output is correct
38 Correct 14 ms 2652 KB Output is correct
39 Correct 14 ms 2796 KB Output is correct
40 Correct 14 ms 2648 KB Output is correct
41 Correct 16 ms 3120 KB Output is correct
42 Correct 14 ms 2652 KB Output is correct
43 Correct 14 ms 2652 KB Output is correct
44 Correct 14 ms 2652 KB Output is correct
45 Correct 14 ms 2648 KB Output is correct
46 Correct 15 ms 2652 KB Output is correct
47 Correct 14 ms 2652 KB Output is correct
48 Correct 14 ms 2788 KB Output is correct
49 Correct 14 ms 2652 KB Output is correct
50 Correct 14 ms 2652 KB Output is correct
51 Correct 14 ms 2800 KB Output is correct
52 Runtime error 48 ms 27984 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -