Submission #891414

#TimeUsernameProblemLanguageResultExecution timeMemory
891414ClHg2Potatoes and fertilizers (LMIO19_bulves)C++14
24 / 100
69 ms16984 KiB
#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 (stderr)

bulves.cpp:2: warning: "EVAL" redefined
    2 | #define EVAL(x) #x " = " << (x)
      | 
<command-line>: note: this is the location of the previous definition
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...