Submission #279641

#TimeUsernameProblemLanguageResultExecution timeMemory
279641arnold518A Game with Grundy (CCO20_day1problem1)C++14
25 / 25
226 ms16356 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N; ll L, R, Y; map<ll, int> M; ll ans[MAXN+10]; int main() { scanf("%d", &N); scanf("%lld%lld%lld", &L, &R, &Y); for(int i=1; i<=N; i++) { ll x, v, h; scanf("%lld%lld%lld", &x, &h, &v); ll d=(v*Y+h-1)/h-1; ll l=x-d, r=x+d; l=max(l, L); r=min(r, R); if(l<=r) { M[l]++; M[r+1]--; } } M[L]; M[R+1]; int sum=0; for(auto it=M.begin(); next(it)!=M.end(); it++) { sum+=it->second; ans[sum]+=next(it)->first-it->first; } for(int i=1; i<=N; i++) ans[i]+=ans[i-1]; for(int i=0; i<=N; i++) printf("%lld\n", ans[i]); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
Main.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |  scanf("%lld%lld%lld", &L, &R, &Y);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |   scanf("%lld%lld%lld", &x, &h, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...