Submission #1048205

# Submission time Handle Problem Language Result Execution time Memory
1048205 2024-08-08T05:12:29 Z 김은성(#11035) Bikeparking (EGOI24_bikeparking) C++17
25 / 100
27 ms 5128 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x[300009], y[300009];
int main(){
	int n, i;
	ll sum = 0;
	scanf("%d", &n);
	for(i=1; i<=n; i++){
		scanf("%lld", &x[i]);
	}
	for(i=1; i<=n; i++){
		scanf("%lld", &y[i]);
		sum += y[i];
	}
	for(i=1; i<=n; i++){
		if(sum < x[i]){
			x[i] = sum;
			sum = 0;
		}
		else
			sum -= x[i];
	}
	int fr = 1, bk = n;
	ll ans = 0;
	for(i=1; i<=n; i++){
		while(fr < i && y[i] > 0){
			if(y[i] >= x[fr]){
				y[i] -= x[fr];
				ans += x[fr];
				x[fr] = 0;
				fr++;
			}
			else{
				ans += y[i];
				x[fr] -= y[i];
				y[i] = 0;
			}
		}
		while(y[i] > 0){
			if(y[i] >= x[bk]){
				y[i] -= x[bk];
				if(bk > i)
					ans -= x[bk];
				bk--;
			}
			else{
				if(bk > i)
					ans -= y[i];
				x[bk] -= y[i];
				y[i] = 0;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
Main.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%lld", &x[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
Main.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%lld", &y[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 23 ms 4956 KB Output is correct
6 Correct 23 ms 4952 KB Output is correct
7 Correct 27 ms 5128 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 22 ms 4956 KB Output is correct
3 Correct 23 ms 4956 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 27 ms 5056 KB Output is correct
11 Incorrect 27 ms 5108 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 0 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 0 ms 2396 KB Output is correct
34 Correct 0 ms 2396 KB Output is correct
35 Correct 0 ms 2392 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 0 ms 2396 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Incorrect 0 ms 2396 KB Output isn't correct
51 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 0 ms 2396 KB Output is correct
26 Correct 23 ms 4956 KB Output is correct
27 Correct 23 ms 4952 KB Output is correct
28 Correct 27 ms 5128 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 0 ms 2396 KB Output is correct
33 Correct 22 ms 4956 KB Output is correct
34 Correct 23 ms 4956 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 ms 2392 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 27 ms 5056 KB Output is correct
42 Incorrect 27 ms 5108 KB Output isn't correct
43 Halted 0 ms 0 KB -