# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
891414 | 2023-12-23T01:15:01 Z | ClHg2 | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 69 ms | 16984 KB |
#include <bits/stdc++.h> #define EVAL(x) #x " = " << (x) using std::cin; using std::cout; using i64 = int64_t; auto main() -> int { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); auto n = 0; cin >> n; auto a = std::vector<int>(n); for (auto i = 0; i < n; ++i) { auto x = 0, y = 0; cin >> x >> y; a[i] = x - y; } auto pre = std::vector<i64>(n + 1); for (auto i = 0; i < n; ++i) pre[i + 1] = pre[i] + a[i]; auto suf = std::vector<i64>(n + 1); for (auto i = n - 1; ~i; --i) suf[i] = suf[i + 1] + a[i]; auto ans = i64{0}; for (auto i = 1; i < n; ++i) { if (pre[i] < 0) ans -= pre[i]; else if (suf[i] < 0) ans -= suf[i]; } cout << ans << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 5 ms | 1628 KB | Output is correct |
5 | Correct | 11 ms | 3028 KB | Output is correct |
6 | Correct | 32 ms | 8588 KB | Output is correct |
7 | Correct | 69 ms | 16984 KB | Output is correct |
8 | Correct | 55 ms | 15060 KB | Output is correct |
9 | Correct | 55 ms | 14428 KB | Output is correct |
10 | Correct | 40 ms | 12116 KB | Output is correct |
11 | Correct | 40 ms | 12132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 5 ms | 1628 KB | Output is correct |
5 | Correct | 11 ms | 3028 KB | Output is correct |
6 | Correct | 32 ms | 8588 KB | Output is correct |
7 | Correct | 69 ms | 16984 KB | Output is correct |
8 | Correct | 55 ms | 15060 KB | Output is correct |
9 | Correct | 55 ms | 14428 KB | Output is correct |
10 | Correct | 40 ms | 12116 KB | Output is correct |
11 | Correct | 40 ms | 12132 KB | Output is correct |
12 | Incorrect | 17 ms | 4440 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 344 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 344 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Incorrect | 0 ms | 344 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |