답안 #945667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
945667 2024-03-14T06:11:15 Z vjudge1 Art Exhibition (JOI18_art) C++17
50 / 100
65 ms 43604 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];
    ll lf[n + 1], rf[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 = p[1].s;
    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;
        ans = max(ans, p[i].s);
    }
    for(int i = 1; i <= n; i++){
        rf[i] = pr[i] - p[i].f;
        lf[i] = p[i].f - pr[i - 1];
    }
    ll mx = 0;
    for(int r = 1; r <= n; r++){
        ans = max(ans, rf[r] + mx);
        mx = max(lf[r], mx);
    }
    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();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 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 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 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 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 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 2648 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 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 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 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 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 2648 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 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 3 ms 2904 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 2 ms 2840 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2788 KB Output is correct
48 Correct 2 ms 2648 KB Output is correct
49 Correct 2 ms 2652 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2512 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 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 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 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 2648 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 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 3 ms 2904 KB Output is correct
32 Correct 2 ms 2648 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 2 ms 2840 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2652 KB Output is correct
47 Correct 2 ms 2788 KB Output is correct
48 Correct 2 ms 2648 KB Output is correct
49 Correct 2 ms 2652 KB Output is correct
50 Correct 2 ms 2652 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Runtime error 65 ms 43604 KB Execution killed with signal 11
53 Halted 0 ms 0 KB -