Submission #766167

#TimeUsernameProblemLanguageResultExecution timeMemory
766167Tenis0206A Game with Grundy (CCO20_day1problem1)C++11
0 / 25
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int nmax = 1e5; int n,l,r,y; vector<pair<int,int>> eves; int rez[nmax + 5]; int pint(double x) { if(x >= 0) { return (int)(x); } return (int)(x) - 1; } int main() { ios::sync_with_stdio(false); cin.tie(0); #ifdef home freopen("nr.in","r",stdin); freopen("nr.out","w",stdout); #endif // home cin>>n; cin>>l>>r>>y; for(int i=1; i<=n; i++) { int x,v,h; cin>>x>>v>>h; double st = 1.0 * y * (1.0 * -h / v) + x; double dr = 1.0 * y * (1.0 * h / v) + x; if(st >= r || dr <= l) { continue; } int st_ev = pint(st) + 1; int dr_ev = 0; if(pint(dr)==dr) { dr_ev = pint(dr); } else { dr_ev = pint(dr) + 1; } if(st_ev < l) { st_ev = l; } if(dr_ev > r) { dr_ev = r + 1; } eves.push_back({st_ev,+1}); eves.push_back({dr_ev,-1}); } sort(eves.begin(),eves.end()); int last = l; int cur = 0; for(auto it : eves) { int poz = it.first; int val = it.second; rez[cur] += poz - last; cur += val; last = poz; } rez[cur] += r - last + 1; for(int i=0;i<=n;i++) { if(i) { rez[i] += rez[i - 1]; } cout<<rez[i]<<'\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...