답안 #75212

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
75212 2018-09-08T17:04:36 Z vex Art Exhibition (JOI18_art) C++14
100 / 100
275 ms 92276 KB
#include <bits/stdc++.h>
#define maxn 500005
#define pll pair<long long,long long>
#define f first
#define s second
using namespace std;

int n;
pll a[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i].f>>a[i].s;

    sort(a,a+n);
    for(int i=1;i<n;i++)a[i].s+=a[i-1].s;

    long long sol=a[0].s;
    long long minn=-a[0].f;
    for(int i=1;i<n;i++)
    {
        long long x=a[i].s-a[i].f;
        if(a[i-1].s-a[i].f<minn)minn=a[i-1].s-a[i].f;
        x-=minn;
        if(sol<x)sol=x;
    }
    cout<<sol<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 3 ms 808 KB Output is correct
19 Correct 3 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 808 KB Output is correct
22 Correct 2 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 2 ms 808 KB Output is correct
26 Correct 2 ms 812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 3 ms 808 KB Output is correct
19 Correct 3 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 808 KB Output is correct
22 Correct 2 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 2 ms 808 KB Output is correct
26 Correct 2 ms 812 KB Output is correct
27 Correct 4 ms 928 KB Output is correct
28 Correct 6 ms 1056 KB Output is correct
29 Correct 5 ms 1312 KB Output is correct
30 Correct 4 ms 1312 KB Output is correct
31 Correct 4 ms 1440 KB Output is correct
32 Correct 5 ms 1568 KB Output is correct
33 Correct 4 ms 1724 KB Output is correct
34 Correct 4 ms 1880 KB Output is correct
35 Correct 5 ms 2008 KB Output is correct
36 Correct 6 ms 2080 KB Output is correct
37 Correct 4 ms 2208 KB Output is correct
38 Correct 5 ms 2360 KB Output is correct
39 Correct 4 ms 2464 KB Output is correct
40 Correct 4 ms 2592 KB Output is correct
41 Correct 4 ms 2848 KB Output is correct
42 Correct 5 ms 2848 KB Output is correct
43 Correct 5 ms 3084 KB Output is correct
44 Correct 4 ms 3100 KB Output is correct
45 Correct 4 ms 3228 KB Output is correct
46 Correct 4 ms 3356 KB Output is correct
47 Correct 4 ms 3484 KB Output is correct
48 Correct 6 ms 3612 KB Output is correct
49 Correct 5 ms 3740 KB Output is correct
50 Correct 5 ms 3868 KB Output is correct
51 Correct 5 ms 3996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 3 ms 668 KB Output is correct
6 Correct 2 ms 668 KB Output is correct
7 Correct 2 ms 668 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
11 Correct 2 ms 732 KB Output is correct
12 Correct 2 ms 788 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 2 ms 808 KB Output is correct
15 Correct 2 ms 808 KB Output is correct
16 Correct 2 ms 808 KB Output is correct
17 Correct 2 ms 808 KB Output is correct
18 Correct 3 ms 808 KB Output is correct
19 Correct 3 ms 808 KB Output is correct
20 Correct 2 ms 808 KB Output is correct
21 Correct 2 ms 808 KB Output is correct
22 Correct 2 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 2 ms 808 KB Output is correct
26 Correct 2 ms 812 KB Output is correct
27 Correct 4 ms 928 KB Output is correct
28 Correct 6 ms 1056 KB Output is correct
29 Correct 5 ms 1312 KB Output is correct
30 Correct 4 ms 1312 KB Output is correct
31 Correct 4 ms 1440 KB Output is correct
32 Correct 5 ms 1568 KB Output is correct
33 Correct 4 ms 1724 KB Output is correct
34 Correct 4 ms 1880 KB Output is correct
35 Correct 5 ms 2008 KB Output is correct
36 Correct 6 ms 2080 KB Output is correct
37 Correct 4 ms 2208 KB Output is correct
38 Correct 5 ms 2360 KB Output is correct
39 Correct 4 ms 2464 KB Output is correct
40 Correct 4 ms 2592 KB Output is correct
41 Correct 4 ms 2848 KB Output is correct
42 Correct 5 ms 2848 KB Output is correct
43 Correct 5 ms 3084 KB Output is correct
44 Correct 4 ms 3100 KB Output is correct
45 Correct 4 ms 3228 KB Output is correct
46 Correct 4 ms 3356 KB Output is correct
47 Correct 4 ms 3484 KB Output is correct
48 Correct 6 ms 3612 KB Output is correct
49 Correct 5 ms 3740 KB Output is correct
50 Correct 5 ms 3868 KB Output is correct
51 Correct 5 ms 3996 KB Output is correct
52 Correct 275 ms 24420 KB Output is correct
53 Correct 233 ms 37064 KB Output is correct
54 Correct 227 ms 49972 KB Output is correct
55 Correct 232 ms 62352 KB Output is correct
56 Correct 229 ms 74880 KB Output is correct
57 Correct 228 ms 87540 KB Output is correct
58 Correct 233 ms 92276 KB Output is correct
59 Correct 225 ms 92276 KB Output is correct
60 Correct 259 ms 92276 KB Output is correct
61 Correct 226 ms 92276 KB Output is correct
62 Correct 245 ms 92276 KB Output is correct
63 Correct 241 ms 92276 KB Output is correct
64 Correct 232 ms 92276 KB Output is correct
65 Correct 246 ms 92276 KB Output is correct
66 Correct 236 ms 92276 KB Output is correct
67 Correct 234 ms 92276 KB Output is correct
68 Correct 240 ms 92276 KB Output is correct