Submission #1026153

#TimeUsernameProblemLanguageResultExecution timeMemory
1026153snpmrnhlolCoin Collecting (JOI19_ho_t4)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 1e5; struct xy{ ll x,y; }v[N*2]; ll f[2]; int main(){ ll n,m; ll ans = 0; cin>>n; for(ll i = 0;i < 2*n;i++){ cin>>v[i].x>>v[i].y; v[i].x--;v[i].y--; } sort(v,v + n*2,[&](xy a,xy b){ return a.x < b.x; }); ll i = 0,j = 0; ll last = -1; while(i < n*2){ j = i; f[0] = 0;f[1] = 0; if(last == 0)f[0]++; else if(last == 1)f[1]++; last = -1; while(j < n*2 && v[j].x == v[i].x){ ans+=abs(v[j].x - j/2) + min(abs(v[j].y - 0),abs(v[j].y - 1)); if(v[j].y <= 0)f[0]++; else f[1]++; j++; } if(f[0] > f[1]){ f[0]-=f[1]; ans+=f[0]/2; if(f[0]%2 == 1){ last = 0; } }else{ f[1]-=f[0]; ans+=f[1]/2; if(f[1]%2 == 1){ last = 1; } } ///i -> j - 1 fuck my wife i = j; } cout<<ans<<'\n'; return 0; }

Compilation message (stderr)

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:10:10: warning: unused variable 'm' [-Wunused-variable]
   10 |     ll n,m;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...