Submission #334796

#TimeUsernameProblemLanguageResultExecution timeMemory
334796ChrisTCoin Collecting (JOI19_ho_t4)C++17
100 / 100
69 ms4972 KiB
#include <bits/stdc++.h> using namespace std; const int MN = 1e5 + 5; int ree[MN][3]; int main() { int n; scanf ("%d",&n); long long ret = 0; for (int i = 1; i <= 2 * n; i++) { int x,y; scanf ("%d %d",&x,&y); if (x < 1) ret += 1-x, x=1; if (x > n) ret += x-n, x=n; if (y < 1) ret += 1-y, y=1; if (y > 2) ret += y-2, y=2; ++ree[x][y]; } int cnt01=0, cnt02=0, cnt11=0, cnt12=0; for (int i = 1; i <= n; i++) { if (!ree[i][1]) { //blue 1 ++cnt01; } if (!ree[i][2]) { //blue 2 ++cnt02; } while (ree[i][1] > 1) { //red 1 ++cnt11; --ree[i][1]; } while (ree[i][2] > 1) { //red 2 ++cnt12; --ree[i][2]; } while (cnt01 && cnt11) { cnt01--; cnt11--; } while (cnt02 && cnt12) { cnt02--; cnt12--; } while (cnt01 && cnt12) { cnt01--; cnt12--; ret++; } while (cnt02 && cnt11) { cnt02--; cnt11--; ret++; } ret += cnt01 + cnt02 + cnt11 + cnt12; } printf ("%lld\n",ret); return 0; }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:7:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf ("%d",&n); long long ret = 0;
      |  ~~~~~~^~~~~~~~~
joi2019_ho_t4.cpp:10:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |   scanf ("%d %d",&x,&y);
      |   ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...