답안 #1048204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1048204 2024-08-08T05:11:21 Z 김은성(#11035) Bikeparking (EGOI24_bikeparking) C++17
9 / 100
28 ms 5136 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;
		}
		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]);
      |   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 22 ms 5136 KB Output is correct
6 Correct 22 ms 4956 KB Output is correct
7 Correct 28 ms 4952 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 22 ms 5132 KB Output is correct
3 Correct 22 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 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 27 ms 4956 KB Output is correct
11 Incorrect 27 ms 5052 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Halted 0 ms 0 KB -