Submission #587928

#TimeUsernameProblemLanguageResultExecution timeMemory
587928jmyszka2007Potatoes and fertilizers (LMIO19_bulves)C++17
20 / 100
15 ms1416 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int>a(n + 1); vector<int>b(n + 1); for(int i = 1; i <= n; i++) { scanf("%d%d", &a[i], &b[i]); } int ans = 0; int d = 0; priority_queue<int>q; for(int i = 1; i <= n; i++) { d += a[i] - b[i]; ans += abs(d); if(d < 0) { q.push(0); q.push(0); } else { q.push(d); q.push(d); } q.pop(); } while(!q.empty()) { int x = q.top(); q.pop(); ans -= min(x, d); } printf("%d\n", ans); }

Compilation message (stderr)

bulves.cpp: In function 'int main()':
bulves.cpp:5:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
bulves.cpp:9:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |   scanf("%d%d", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...