답안 #146934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
146934 2019-08-26T17:07:22 Z Bruteforceman Potatoes and fertilizers (LMIO19_bulves) C++11
24 / 100
133 ms 12152 KB
#include "bits/stdc++.h"
using namespace std;
typedef pair <int, int> pii;
int a[1000010], b[1000010];
long long pre[1000010], suf[1000010];

int main(int argc, char const *argv[])
{
	ios_base :: sync_with_stdio (false);
	cin.tie (0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
	}
	for(int i = 1; i <= n; i++) {
		pre[i] = pre[i - 1] + a[i] - b[i];
	}
	for(int i = n; i >= 1; i--) {
		suf[i] = suf[i + 1] + a[i] - b[i];
	}
	long long ans = 0;
	for(int i = 1; i < n; i++) {
		if(pre[i] < 0) {
			ans -= pre[i];
		}
		if(suf[i + 1] < 0) {
			ans -= suf[i + 1];
		}
	}
	cout << ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 11 ms 1500 KB Output is correct
5 Correct 22 ms 2680 KB Output is correct
6 Correct 63 ms 6236 KB Output is correct
7 Correct 133 ms 12132 KB Output is correct
8 Correct 100 ms 12140 KB Output is correct
9 Correct 108 ms 12080 KB Output is correct
10 Correct 83 ms 12152 KB Output is correct
11 Correct 77 ms 12024 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 3 ms 504 KB Output is correct
4 Correct 11 ms 1500 KB Output is correct
5 Correct 22 ms 2680 KB Output is correct
6 Correct 63 ms 6236 KB Output is correct
7 Correct 133 ms 12132 KB Output is correct
8 Correct 100 ms 12140 KB Output is correct
9 Correct 108 ms 12080 KB Output is correct
10 Correct 83 ms 12152 KB Output is correct
11 Correct 77 ms 12024 KB Output is correct
12 Incorrect 33 ms 3448 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 248 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Incorrect 2 ms 248 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Incorrect 2 ms 248 KB Output isn't correct
5 Halted 0 ms 0 KB -