답안 #225189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
225189 2020-04-19T13:16:07 Z muhammad_hokimiyon Art Exhibition (JOI18_art) C++14
100 / 100
407 ms 50284 KB
#include <bits/stdc++.h>

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 5e5 + 7;
const int M = 6;
const int mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

int n;
ll a[N];
ll b[N];
ll sum[N];

void solve1()
{
    cin >> n;
    vector < int > v;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i] >> b[i];
        v.push_back(i);
    }
    sort( v.begin() , v.end() , [&] ( int i , int j ){
        return a[i] < a[j];
    } );
    set < ll > s;
    for( int h = 1; h <= n; h++ ){
        int i = v[h - 1];
        sum[h] = sum[h - 1] + b[i];
    }
    ll ans = -1e18;
    for( int h = 1; h <= n; h++ ){
        int i = v[h - 1];
        s.insert( sum[h - 1] - a[i] );
        auto x = *s.begin();
        ans = max( ans , sum[h] - a[i] - x );
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 432 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 432 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 7 ms 768 KB Output is correct
28 Correct 8 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 8 ms 768 KB Output is correct
31 Correct 7 ms 768 KB Output is correct
32 Correct 7 ms 768 KB Output is correct
33 Correct 9 ms 768 KB Output is correct
34 Correct 7 ms 768 KB Output is correct
35 Correct 7 ms 768 KB Output is correct
36 Correct 8 ms 768 KB Output is correct
37 Correct 7 ms 768 KB Output is correct
38 Correct 8 ms 768 KB Output is correct
39 Correct 8 ms 768 KB Output is correct
40 Correct 10 ms 768 KB Output is correct
41 Correct 7 ms 768 KB Output is correct
42 Correct 7 ms 768 KB Output is correct
43 Correct 8 ms 768 KB Output is correct
44 Correct 8 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 8 ms 768 KB Output is correct
47 Correct 7 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 7 ms 768 KB Output is correct
51 Correct 8 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 432 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 7 ms 768 KB Output is correct
28 Correct 8 ms 768 KB Output is correct
29 Correct 7 ms 768 KB Output is correct
30 Correct 8 ms 768 KB Output is correct
31 Correct 7 ms 768 KB Output is correct
32 Correct 7 ms 768 KB Output is correct
33 Correct 9 ms 768 KB Output is correct
34 Correct 7 ms 768 KB Output is correct
35 Correct 7 ms 768 KB Output is correct
36 Correct 8 ms 768 KB Output is correct
37 Correct 7 ms 768 KB Output is correct
38 Correct 8 ms 768 KB Output is correct
39 Correct 8 ms 768 KB Output is correct
40 Correct 10 ms 768 KB Output is correct
41 Correct 7 ms 768 KB Output is correct
42 Correct 7 ms 768 KB Output is correct
43 Correct 8 ms 768 KB Output is correct
44 Correct 8 ms 768 KB Output is correct
45 Correct 7 ms 768 KB Output is correct
46 Correct 8 ms 768 KB Output is correct
47 Correct 7 ms 768 KB Output is correct
48 Correct 7 ms 768 KB Output is correct
49 Correct 7 ms 768 KB Output is correct
50 Correct 7 ms 768 KB Output is correct
51 Correct 8 ms 768 KB Output is correct
52 Correct 319 ms 44940 KB Output is correct
53 Correct 372 ms 50240 KB Output is correct
54 Correct 342 ms 50276 KB Output is correct
55 Correct 359 ms 50268 KB Output is correct
56 Correct 394 ms 50152 KB Output is correct
57 Correct 407 ms 50260 KB Output is correct
58 Correct 365 ms 50284 KB Output is correct
59 Correct 358 ms 50196 KB Output is correct
60 Correct 353 ms 50220 KB Output is correct
61 Correct 355 ms 50024 KB Output is correct
62 Correct 353 ms 50212 KB Output is correct
63 Correct 363 ms 50280 KB Output is correct
64 Correct 357 ms 50152 KB Output is correct
65 Correct 339 ms 50152 KB Output is correct
66 Correct 351 ms 50284 KB Output is correct
67 Correct 343 ms 50152 KB Output is correct
68 Correct 362 ms 50152 KB Output is correct