Submission #125580

#TimeUsernameProblemLanguageResultExecution timeMemory
125580wilwxkCoin Collecting (JOI19_ho_t4)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN=2e3+5; const ll INF=1e15+9; vector<ll> v; int n, cont; ll respf; int main() { scanf("%d", &n); n*=2; for(int i=1; i<=n; i++) { int a, b; scanf("%d %d", &a, &b); if(a<1||a>n) { if(a<1) respf+=1-a, a=1; else respf+=a-n, a=n; } if(b>=2) cont++; respf+=min(llabs(b-1), llabs(b-2)); v.push_back(a); } respf+=llabs(n/2-cont); sort(v.begin(), v.end()); int ind=0; for(int i=0; i<n; i++) { ll cur=i/2+1; // printf("adsby %d %lld //%lld\n", cur, ind, respf); respf+=llabs(v[ind++]-cur); } printf("%lld\n", respf); }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n); n*=2;
  ~~~~~^~~~~~~~~~
joi2019_ho_t4.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d %d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...