Submission #51954

# Submission time Handle Problem Language Result Execution time Memory
51954 2018-06-22T17:40:22 Z TadijaSebez Art Exhibition (JOI18_art) C++11
100 / 100
458 ms 237048 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
const int N=500050;
ll a[N],b[N],c[N],d[N];
int id[N];
bool comp(int i, int j){ return c[i]<c[j];}
const ll inf=1e18;
ll max(ll a, ll b){ return a>b?a:b;}
int main()
{
	int n,i;
	scanf("%i",&n);
	for(i=1;i<=n;i++) scanf("%lld %lld",&c[i],&d[i]),id[i]=i;
	sort(id+1,id+1+n,comp);
	for(i=1;i<=n;i++) a[i]=c[id[i]],b[i]=b[i-1]+d[id[i]];
	ll best=-inf,sol=-inf;
	for(i=1;i<=n;i++)
	{
		best=max(best,a[i]-b[i-1]);
		sol=max(sol,best-a[i]+b[i]);
	}
	printf("%lld\n",sol);
	return 0;
}

Compilation message

art.cpp: In function 'int main()':
art.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
art.cpp:15:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%lld %lld",&c[i],&d[i]),id[i]=i;
                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 3 ms 628 KB Output is correct
7 Correct 3 ms 740 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 3 ms 628 KB Output is correct
7 Correct 3 ms 740 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 3 ms 892 KB Output is correct
21 Correct 2 ms 900 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 2 ms 940 KB Output is correct
25 Correct 2 ms 948 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 3 ms 628 KB Output is correct
7 Correct 3 ms 740 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 3 ms 892 KB Output is correct
21 Correct 2 ms 900 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 2 ms 940 KB Output is correct
25 Correct 2 ms 948 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
27 Correct 6 ms 1220 KB Output is correct
28 Correct 5 ms 1348 KB Output is correct
29 Correct 5 ms 1476 KB Output is correct
30 Correct 5 ms 1604 KB Output is correct
31 Correct 5 ms 1732 KB Output is correct
32 Correct 5 ms 1860 KB Output is correct
33 Correct 5 ms 1980 KB Output is correct
34 Correct 5 ms 2116 KB Output is correct
35 Correct 5 ms 2244 KB Output is correct
36 Correct 6 ms 2372 KB Output is correct
37 Correct 5 ms 2572 KB Output is correct
38 Correct 6 ms 2700 KB Output is correct
39 Correct 5 ms 2756 KB Output is correct
40 Correct 6 ms 2884 KB Output is correct
41 Correct 5 ms 3012 KB Output is correct
42 Correct 5 ms 3076 KB Output is correct
43 Correct 5 ms 3264 KB Output is correct
44 Correct 5 ms 3392 KB Output is correct
45 Correct 6 ms 3464 KB Output is correct
46 Correct 5 ms 3648 KB Output is correct
47 Correct 5 ms 3776 KB Output is correct
48 Correct 9 ms 3904 KB Output is correct
49 Correct 8 ms 4032 KB Output is correct
50 Correct 6 ms 4160 KB Output is correct
51 Correct 5 ms 4288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 360 KB Output is correct
3 Correct 2 ms 472 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 624 KB Output is correct
6 Correct 3 ms 628 KB Output is correct
7 Correct 3 ms 740 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 2 ms 772 KB Output is correct
11 Correct 2 ms 776 KB Output is correct
12 Correct 3 ms 780 KB Output is correct
13 Correct 3 ms 788 KB Output is correct
14 Correct 3 ms 812 KB Output is correct
15 Correct 3 ms 820 KB Output is correct
16 Correct 2 ms 828 KB Output is correct
17 Correct 2 ms 836 KB Output is correct
18 Correct 2 ms 860 KB Output is correct
19 Correct 3 ms 884 KB Output is correct
20 Correct 3 ms 892 KB Output is correct
21 Correct 2 ms 900 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 2 ms 932 KB Output is correct
24 Correct 2 ms 940 KB Output is correct
25 Correct 2 ms 948 KB Output is correct
26 Correct 2 ms 956 KB Output is correct
27 Correct 6 ms 1220 KB Output is correct
28 Correct 5 ms 1348 KB Output is correct
29 Correct 5 ms 1476 KB Output is correct
30 Correct 5 ms 1604 KB Output is correct
31 Correct 5 ms 1732 KB Output is correct
32 Correct 5 ms 1860 KB Output is correct
33 Correct 5 ms 1980 KB Output is correct
34 Correct 5 ms 2116 KB Output is correct
35 Correct 5 ms 2244 KB Output is correct
36 Correct 6 ms 2372 KB Output is correct
37 Correct 5 ms 2572 KB Output is correct
38 Correct 6 ms 2700 KB Output is correct
39 Correct 5 ms 2756 KB Output is correct
40 Correct 6 ms 2884 KB Output is correct
41 Correct 5 ms 3012 KB Output is correct
42 Correct 5 ms 3076 KB Output is correct
43 Correct 5 ms 3264 KB Output is correct
44 Correct 5 ms 3392 KB Output is correct
45 Correct 6 ms 3464 KB Output is correct
46 Correct 5 ms 3648 KB Output is correct
47 Correct 5 ms 3776 KB Output is correct
48 Correct 9 ms 3904 KB Output is correct
49 Correct 8 ms 4032 KB Output is correct
50 Correct 6 ms 4160 KB Output is correct
51 Correct 5 ms 4288 KB Output is correct
52 Correct 362 ms 34320 KB Output is correct
53 Correct 331 ms 47052 KB Output is correct
54 Correct 371 ms 59792 KB Output is correct
55 Correct 332 ms 72468 KB Output is correct
56 Correct 315 ms 85092 KB Output is correct
57 Correct 333 ms 97768 KB Output is correct
58 Correct 332 ms 110460 KB Output is correct
59 Correct 312 ms 123068 KB Output is correct
60 Correct 347 ms 135836 KB Output is correct
61 Correct 324 ms 148360 KB Output is correct
62 Correct 345 ms 160960 KB Output is correct
63 Correct 314 ms 173656 KB Output is correct
64 Correct 314 ms 186308 KB Output is correct
65 Correct 338 ms 199052 KB Output is correct
66 Correct 458 ms 211680 KB Output is correct
67 Correct 373 ms 224360 KB Output is correct
68 Correct 340 ms 237048 KB Output is correct