Submission #285140

# Submission time Handle Problem Language Result Execution time Memory
285140 2020-08-28T11:04:42 Z Pyqe Potatoes and fertilizers (LMIO19_bulves) C++14
100 / 100
228 ms 15336 KB
#include <bits/stdc++.h>

using namespace std;

long long n,ps[500069];
priority_queue<long long> pq;

int main()
{
	long long i,ii,k,l,z=0;
	
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld%lld",&k,&l);
		ps[i]=ps[i-1]+k-l;
	}
	for(i=1;i<n;i++)
	{
		k=min(max(ps[i],0ll),ps[n]);
		z+=abs(k-ps[i]);
		ps[i]=k;
		if(i-1)
		{
			z+=max(pq.top()-ps[i],0ll);
		}
		for(ii=0;ii<2;ii++)
		{
			pq.push(ps[i]);
		}
		pq.pop();
	}
	printf("%lld\n",z);
}

Compilation message

bulves.cpp: In function 'int main()':
bulves.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
bulves.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |   scanf("%lld%lld",&k,&l);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 13 ms 1660 KB Output is correct
5 Correct 33 ms 2928 KB Output is correct
6 Correct 87 ms 7788 KB Output is correct
7 Correct 181 ms 15216 KB Output is correct
8 Correct 129 ms 13288 KB Output is correct
9 Correct 148 ms 12648 KB Output is correct
10 Correct 132 ms 10504 KB Output is correct
11 Correct 131 ms 10472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 13 ms 1660 KB Output is correct
5 Correct 33 ms 2928 KB Output is correct
6 Correct 87 ms 7788 KB Output is correct
7 Correct 181 ms 15216 KB Output is correct
8 Correct 129 ms 13288 KB Output is correct
9 Correct 148 ms 12648 KB Output is correct
10 Correct 132 ms 10504 KB Output is correct
11 Correct 131 ms 10472 KB Output is correct
12 Correct 46 ms 4208 KB Output is correct
13 Correct 110 ms 10984 KB Output is correct
14 Correct 183 ms 15208 KB Output is correct
15 Correct 136 ms 13416 KB Output is correct
16 Correct 145 ms 12716 KB Output is correct
17 Correct 130 ms 10472 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 13 ms 1660 KB Output is correct
12 Correct 33 ms 2928 KB Output is correct
13 Correct 87 ms 7788 KB Output is correct
14 Correct 181 ms 15216 KB Output is correct
15 Correct 129 ms 13288 KB Output is correct
16 Correct 148 ms 12648 KB Output is correct
17 Correct 132 ms 10504 KB Output is correct
18 Correct 131 ms 10472 KB Output is correct
19 Correct 46 ms 4208 KB Output is correct
20 Correct 110 ms 10984 KB Output is correct
21 Correct 183 ms 15208 KB Output is correct
22 Correct 136 ms 13416 KB Output is correct
23 Correct 145 ms 12716 KB Output is correct
24 Correct 130 ms 10472 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 53 ms 4080 KB Output is correct
33 Correct 134 ms 10940 KB Output is correct
34 Correct 228 ms 15208 KB Output is correct
35 Correct 191 ms 12772 KB Output is correct
36 Correct 150 ms 13288 KB Output is correct
37 Correct 211 ms 15208 KB Output is correct
38 Correct 133 ms 11368 KB Output is correct
39 Correct 139 ms 10980 KB Output is correct
40 Correct 139 ms 10472 KB Output is correct
41 Correct 135 ms 10472 KB Output is correct
42 Correct 137 ms 10468 KB Output is correct
43 Correct 140 ms 10484 KB Output is correct
44 Correct 190 ms 15336 KB Output is correct
45 Correct 161 ms 10812 KB Output is correct
46 Correct 132 ms 10284 KB Output is correct
47 Correct 1 ms 384 KB Output is correct