Submission #466166

#TimeUsernameProblemLanguageResultExecution timeMemory
466166jamezzzCoin Collecting (JOI19_ho_t4)C++17
100 / 100
83 ms5688 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vll; mt19937 rng(time(0)); int n,x,y,c[100005][2]; ll ans; int main(){ sf("%d",&n); memset(c,-1,sizeof c); for(int i=0;i<2*n;++i){ sf("%d%d",&x,&y); if(x<1)ans+=1-x,x=1; if(x>n)ans+=x-n,x=n; if(y<1)ans+=1-y,y=1; if(y>2)ans+=y-2,y=2; ++c[x-1][y-1]; } for(int i=0;i<n;++i){ int x=min(abs(c[i][0]),abs(c[i][1])); if(c[i][0]<0&&c[i][1]>0)c[i][0]+=x,c[i][1]-=x,ans+=x; if(c[i][0]>0&&c[i][1]<0)c[i][0]-=x,c[i][1]+=x,ans+=x; ans+=abs(c[i][0])+abs(c[i][1]); c[i+1][0]+=c[i][0],c[i+1][1]+=c[i][1]; } pf("%lld\n",ans); }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:35:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |  sf("%d",&n);
      |    ^
joi2019_ho_t4.cpp:38:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   sf("%d%d",&x,&y);
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...