Submission #231772

#TimeUsernameProblemLanguageResultExecution timeMemory
231772jamielimCoin Collecting (JOI19_ho_t4)C++14
0 / 100
5 ms384 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); int x[2*n],y[2*n]; long long ans=0; for(int i=0;i<2*n;i++){ scanf("%d%d",&x[i],&y[i]); if(x[i]<1){ans+=(long long)(1-x[i]);x[i]=1;} else if(x[i]>n){ans+=(long long)(x[i]-n);x[i]=n;} if(y[i]<1){ans+=(long long)(1-y[i]);y[i]=1;} else if(y[i]>2){ans+=(long long)(y[i]-2);y[i]=2;} } int c=0; for(int i=0;i<2*n;i++)if(y[i]==1)c++; ans+=(long long)abs(n-c); sort(x,x+2*n); for(int i=0;i<2*n;i++){ ans+=(long long)abs(x[i]-(i/2+1)); } printf("%lld",ans); }

Compilation message (stderr)

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