Submission #384710

#TimeUsernameProblemLanguageResultExecution timeMemory
384710AdiZer0Preokret (COCI18_preokret)C++17
35 / 50
2 ms492 KiB
#include <bits/stdc++.h> #define pb push_back #define whole(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; typedef long long ll; typedef long double ld; const int N = (int)1e5 + 7; const int INF = (int)1e9 + 7; const ll linf = (ll)1e18 + 1; int n, a[N]; int m, b[N]; int main() { scanf ("%d", &n); for (int i = 1; i <= n; ++i) scanf ("%d", a + i); scanf ("%d", &m); for (int i = 1; i <= m; ++i) scanf ("%d", b + i); int who = -1, p1 = 1; int half = 0, turn = 0; int numA = 0, numB = 0; for (int i = 1; i <= n;) { if (p1 <= m && a[i] < b[p1]) { if (a[i] <= 1440) ++half; numA++; ++i; } else { if (b[p1] <= 1440) ++half; numB++; ++p1; } if (who == -1) { if (numA > numB) who = 0; else who = 1; } else { if (who) { if (numA > numB) who = 0, ++turn; } else { if (numA < numB) who = 1, ++turn; } } } while (p1 <= m) { ++numB; if (b[p1] <= 1440) ++half; if (who == -1) { if (numA > numB) who = 0; else who = 1; } else { if (who) { if (numA > numB) who = 0, ++turn; } else { if (numA < numB) who = 1, ++turn; } } ++p1; } printf ("%d\n%d\n", half, turn); return 0; } /* 6 15 30 35 55 60 2065 7 20 25 40 45 50 2070 2075 */

Compilation message (stderr)

preokret.cpp: In function 'int main()':
preokret.cpp:20:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf ("%d", &n);
      |     ~~~~~~^~~~~~~~~~
preokret.cpp:21:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
preokret.cpp:22:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     scanf ("%d", &m);
      |     ~~~~~~^~~~~~~~~~
preokret.cpp:23:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |     for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...