답안 #47127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
47127 2018-04-27T21:00:51 Z dqhungdl Art Exhibition (JOI18_art) C++17
100 / 100
773 ms 231104 KB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int64_t,int64_t> ii;
int64_t n,s[500005];
ii a[500005];

int main()
{
    cin>>n;
    for(int64_t i=1;i<=n;i++)
        cin>>a[i].first>>a[i].second;
    sort(a+1,a+n+1);
    for(int64_t i=1;i<=n;i++)
        s[i]=s[i-1]+a[i].second;
    int64_t maxn=-1e18,res=-1e18;
    for(int64_t i=1;i<=n;i++)
    {
        maxn=max(maxn,a[i].first-s[i-1]);
        res=max(res,s[i]-a[i].first+maxn);
    }
    cout<<res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 7 ms 728 KB Output is correct
14 Correct 2 ms 756 KB Output is correct
15 Correct 2 ms 764 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 3 ms 844 KB Output is correct
19 Correct 2 ms 868 KB Output is correct
20 Correct 2 ms 1004 KB Output is correct
21 Correct 2 ms 1012 KB Output is correct
22 Correct 3 ms 1020 KB Output is correct
23 Correct 2 ms 1020 KB Output is correct
24 Correct 2 ms 1020 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 3 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 7 ms 728 KB Output is correct
14 Correct 2 ms 756 KB Output is correct
15 Correct 2 ms 764 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 3 ms 844 KB Output is correct
19 Correct 2 ms 868 KB Output is correct
20 Correct 2 ms 1004 KB Output is correct
21 Correct 2 ms 1012 KB Output is correct
22 Correct 3 ms 1020 KB Output is correct
23 Correct 2 ms 1020 KB Output is correct
24 Correct 2 ms 1020 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 3 ms 1020 KB Output is correct
27 Correct 11 ms 1076 KB Output is correct
28 Correct 12 ms 1204 KB Output is correct
29 Correct 8 ms 1336 KB Output is correct
30 Correct 8 ms 1468 KB Output is correct
31 Correct 8 ms 1588 KB Output is correct
32 Correct 8 ms 1844 KB Output is correct
33 Correct 8 ms 1860 KB Output is correct
34 Correct 8 ms 1992 KB Output is correct
35 Correct 9 ms 2128 KB Output is correct
36 Correct 8 ms 2244 KB Output is correct
37 Correct 8 ms 2380 KB Output is correct
38 Correct 8 ms 2508 KB Output is correct
39 Correct 8 ms 2628 KB Output is correct
40 Correct 9 ms 2756 KB Output is correct
41 Correct 9 ms 2884 KB Output is correct
42 Correct 9 ms 3008 KB Output is correct
43 Correct 9 ms 3136 KB Output is correct
44 Correct 8 ms 3268 KB Output is correct
45 Correct 8 ms 3524 KB Output is correct
46 Correct 8 ms 3680 KB Output is correct
47 Correct 9 ms 3680 KB Output is correct
48 Correct 9 ms 3808 KB Output is correct
49 Correct 12 ms 3940 KB Output is correct
50 Correct 9 ms 4076 KB Output is correct
51 Correct 9 ms 4212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 460 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 648 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 704 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 712 KB Output is correct
11 Correct 2 ms 716 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 7 ms 728 KB Output is correct
14 Correct 2 ms 756 KB Output is correct
15 Correct 2 ms 764 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 3 ms 844 KB Output is correct
19 Correct 2 ms 868 KB Output is correct
20 Correct 2 ms 1004 KB Output is correct
21 Correct 2 ms 1012 KB Output is correct
22 Correct 3 ms 1020 KB Output is correct
23 Correct 2 ms 1020 KB Output is correct
24 Correct 2 ms 1020 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 3 ms 1020 KB Output is correct
27 Correct 11 ms 1076 KB Output is correct
28 Correct 12 ms 1204 KB Output is correct
29 Correct 8 ms 1336 KB Output is correct
30 Correct 8 ms 1468 KB Output is correct
31 Correct 8 ms 1588 KB Output is correct
32 Correct 8 ms 1844 KB Output is correct
33 Correct 8 ms 1860 KB Output is correct
34 Correct 8 ms 1992 KB Output is correct
35 Correct 9 ms 2128 KB Output is correct
36 Correct 8 ms 2244 KB Output is correct
37 Correct 8 ms 2380 KB Output is correct
38 Correct 8 ms 2508 KB Output is correct
39 Correct 8 ms 2628 KB Output is correct
40 Correct 9 ms 2756 KB Output is correct
41 Correct 9 ms 2884 KB Output is correct
42 Correct 9 ms 3008 KB Output is correct
43 Correct 9 ms 3136 KB Output is correct
44 Correct 8 ms 3268 KB Output is correct
45 Correct 8 ms 3524 KB Output is correct
46 Correct 8 ms 3680 KB Output is correct
47 Correct 9 ms 3680 KB Output is correct
48 Correct 9 ms 3808 KB Output is correct
49 Correct 12 ms 3940 KB Output is correct
50 Correct 9 ms 4076 KB Output is correct
51 Correct 9 ms 4212 KB Output is correct
52 Correct 688 ms 28584 KB Output is correct
53 Correct 728 ms 41372 KB Output is correct
54 Correct 761 ms 53908 KB Output is correct
55 Correct 773 ms 66588 KB Output is correct
56 Correct 681 ms 79196 KB Output is correct
57 Correct 669 ms 91912 KB Output is correct
58 Correct 656 ms 104728 KB Output is correct
59 Correct 693 ms 117144 KB Output is correct
60 Correct 691 ms 129896 KB Output is correct
61 Correct 701 ms 142464 KB Output is correct
62 Correct 681 ms 155084 KB Output is correct
63 Correct 715 ms 167952 KB Output is correct
64 Correct 673 ms 180524 KB Output is correct
65 Correct 673 ms 193260 KB Output is correct
66 Correct 682 ms 205828 KB Output is correct
67 Correct 650 ms 218436 KB Output is correct
68 Correct 718 ms 231104 KB Output is correct