Submission #125957

#TimeUsernameProblemLanguageResultExecution timeMemory
125957EntityITCoin Collecting (JOI19_ho_t4)C++14
0 / 100
2 ms380 KiB
#include<bits/stdc++.h> using namespace std; const int N = (int)1e5 + 5; int n, x[N << 1], y[N << 1], cnt[2], z[N << 1]; long long ans; int main () { scanf("%d", &n); for (int i = 1; i <= (n << 1); ++i) scanf("%d %d", x + i, y + i), z[i] = (i + 1) / 2; for (int i = 1; i <= (n << 1); ++i) { if (y[i] < 2) ans += 1 - y[i], ++cnt[0]; else ans += y[i] - 2, ++cnt[1]; } ans += abs(cnt[0] - cnt[1]) / 2; sort(x + 1, x + (n << 1) + 1); for (int i = 1; i <= (n << 1); ++i) ans += abs(x[i] - z[i]); printf("%lld", ans); return 0; }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:11:69: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= (n << 1); ++i) scanf("%d %d", x + i, y + i), z[i] = (i + 1) / 2;
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...