Submission #1239887

#TimeUsernameProblemLanguageResultExecution timeMemory
1239887JerBikeparking (EGOI24_bikeparking)C++20
25 / 100
56 ms2632 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 5; int users[MAXN], slots[MAXN]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &slots[i]); for (int i = 0; i < n; i++) scanf("%d", &users[i]); int res = 0; int curr = 0; for (int i = 0; i < n; i++) { if (curr >= i) continue; if (slots[curr] > users[i]) res += users[i], slots[curr] -= users[i], users[i] = 0; else res += slots[curr], users[i] -= slots[curr], slots[curr] = 0, curr++; } for (int i = 0; i < n; i++) { if (slots[i] <= users[i]) users[i] -= slots[i], slots[i] = 0; else slots[i] -= users[i], users[i] = 0; } for (int i = 0; i < n; i++) res -= users[i]; printf("%d\n", res); return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
Main.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d", &slots[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         scanf("%d", &users[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...