답안 #86062

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86062 2018-11-24T12:06:35 Z rzbt Art Exhibition (JOI18_art) C++14
100 / 100
336 ms 52992 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 500005
typedef long long ll;


using namespace std;


ll n,parc[MAXN];
pair<ll,ll> niz[MAXN];


int main()
{
    scanf("%lld", &n);
    for(int i=1;i<=n;i++)
        scanf("%lld %lld", &niz[i].first,&niz[i].second);
    sort(niz+1,niz+1+n);
    ll mi=-niz[1].first,res=niz[1].second;
    parc[1]=niz[1].second;
    for(int i=2;i<=n;i++){
        parc[i]=parc[i-1]+niz[i].second;
        mi=min(mi,parc[i-1]-niz[i].first);
        res=max(res,parc[i]-niz[i].first-mi);
        //printf("   %lld %lld %lld\n",mi,res,parc[i]);
    }
    printf("%lld",res);

    return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
art.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &niz[i].first,&niz[i].second);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 3 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 3 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 2 ms 796 KB Output is correct
19 Correct 2 ms 796 KB Output is correct
20 Correct 2 ms 796 KB Output is correct
21 Correct 3 ms 796 KB Output is correct
22 Correct 2 ms 796 KB Output is correct
23 Correct 2 ms 796 KB Output is correct
24 Correct 2 ms 796 KB Output is correct
25 Correct 2 ms 796 KB Output is correct
26 Correct 2 ms 796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 3 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 2 ms 796 KB Output is correct
19 Correct 2 ms 796 KB Output is correct
20 Correct 2 ms 796 KB Output is correct
21 Correct 3 ms 796 KB Output is correct
22 Correct 2 ms 796 KB Output is correct
23 Correct 2 ms 796 KB Output is correct
24 Correct 2 ms 796 KB Output is correct
25 Correct 2 ms 796 KB Output is correct
26 Correct 2 ms 796 KB Output is correct
27 Correct 5 ms 924 KB Output is correct
28 Correct 5 ms 1052 KB Output is correct
29 Correct 7 ms 1180 KB Output is correct
30 Correct 5 ms 1424 KB Output is correct
31 Correct 5 ms 1436 KB Output is correct
32 Correct 5 ms 1568 KB Output is correct
33 Correct 5 ms 1692 KB Output is correct
34 Correct 5 ms 1820 KB Output is correct
35 Correct 5 ms 1948 KB Output is correct
36 Correct 7 ms 2076 KB Output is correct
37 Correct 6 ms 2204 KB Output is correct
38 Correct 10 ms 2460 KB Output is correct
39 Correct 5 ms 2460 KB Output is correct
40 Correct 5 ms 2588 KB Output is correct
41 Correct 5 ms 2716 KB Output is correct
42 Correct 5 ms 2852 KB Output is correct
43 Correct 5 ms 2988 KB Output is correct
44 Correct 5 ms 3120 KB Output is correct
45 Correct 5 ms 3228 KB Output is correct
46 Correct 5 ms 3352 KB Output is correct
47 Correct 5 ms 3480 KB Output is correct
48 Correct 5 ms 3608 KB Output is correct
49 Correct 5 ms 3736 KB Output is correct
50 Correct 5 ms 3864 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 376 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Correct 2 ms 532 KB Output is correct
5 Correct 2 ms 552 KB Output is correct
6 Correct 3 ms 672 KB Output is correct
7 Correct 2 ms 672 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 2 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 2 ms 736 KB Output is correct
14 Correct 3 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 796 KB Output is correct
18 Correct 2 ms 796 KB Output is correct
19 Correct 2 ms 796 KB Output is correct
20 Correct 2 ms 796 KB Output is correct
21 Correct 3 ms 796 KB Output is correct
22 Correct 2 ms 796 KB Output is correct
23 Correct 2 ms 796 KB Output is correct
24 Correct 2 ms 796 KB Output is correct
25 Correct 2 ms 796 KB Output is correct
26 Correct 2 ms 796 KB Output is correct
27 Correct 5 ms 924 KB Output is correct
28 Correct 5 ms 1052 KB Output is correct
29 Correct 7 ms 1180 KB Output is correct
30 Correct 5 ms 1424 KB Output is correct
31 Correct 5 ms 1436 KB Output is correct
32 Correct 5 ms 1568 KB Output is correct
33 Correct 5 ms 1692 KB Output is correct
34 Correct 5 ms 1820 KB Output is correct
35 Correct 5 ms 1948 KB Output is correct
36 Correct 7 ms 2076 KB Output is correct
37 Correct 6 ms 2204 KB Output is correct
38 Correct 10 ms 2460 KB Output is correct
39 Correct 5 ms 2460 KB Output is correct
40 Correct 5 ms 2588 KB Output is correct
41 Correct 5 ms 2716 KB Output is correct
42 Correct 5 ms 2852 KB Output is correct
43 Correct 5 ms 2988 KB Output is correct
44 Correct 5 ms 3120 KB Output is correct
45 Correct 5 ms 3228 KB Output is correct
46 Correct 5 ms 3352 KB Output is correct
47 Correct 5 ms 3480 KB Output is correct
48 Correct 5 ms 3608 KB Output is correct
49 Correct 5 ms 3736 KB Output is correct
50 Correct 5 ms 3864 KB Output is correct
51 Correct 5 ms 3996 KB Output is correct
52 Correct 336 ms 28320 KB Output is correct
53 Correct 285 ms 41036 KB Output is correct
54 Correct 268 ms 52788 KB Output is correct
55 Correct 290 ms 52832 KB Output is correct
56 Correct 326 ms 52992 KB Output is correct
57 Correct 275 ms 52992 KB Output is correct
58 Correct 295 ms 52992 KB Output is correct
59 Correct 268 ms 52992 KB Output is correct
60 Correct 261 ms 52992 KB Output is correct
61 Correct 271 ms 52992 KB Output is correct
62 Correct 274 ms 52992 KB Output is correct
63 Correct 291 ms 52992 KB Output is correct
64 Correct 266 ms 52992 KB Output is correct
65 Correct 262 ms 52992 KB Output is correct
66 Correct 286 ms 52992 KB Output is correct
67 Correct 262 ms 52992 KB Output is correct
68 Correct 261 ms 52992 KB Output is correct