이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |