Submission #477341

# Submission time Handle Problem Language Result Execution time Memory
477341 2021-10-01T17:35:01 Z BThero Potatoes and fertilizers (LMIO19_bulves) C++17
0 / 100
1000 ms 976 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}

	ll ans = 0;

	for (int i = 0; i + 1 < n; i++) {
		ll x = 0, y = 0;

		for (int j = 0; j <= i; j++) {
			x += a[j];
			x -= b[j];
		}

		for (int j = i + 1; j < n; j++) {
			y += a[j];
			y -= b[j];
		}

		if (x >= 0 && y >= 0) {
			// ignore
		}
		else if (x >= 0 && y < 0) {
			ans += -y;
		}
		else if (x < 0 && y >= 0) {
			ans += -x;
		}
		else {
			assert(0);
		}
	}
	
	cout << ans << '\n';
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 352 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Execution timed out 1084 ms 976 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 352 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Execution timed out 1084 ms 976 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 352 KB Output is correct
3 Incorrect 0 ms 208 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 352 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Incorrect 0 ms 208 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 352 KB Output is correct
3 Correct 9 ms 376 KB Output is correct
4 Incorrect 0 ms 208 KB Output isn't correct
5 Halted 0 ms 0 KB -