Submission #67609

#TimeUsernameProblemLanguageResultExecution timeMemory
67609imsifileNectar with Coconut Jelly (FXCUP3_nectar)C++98
100 / 100
626 ms1452 KiB
#include<stdio.h> #include<vector> using namespace std; typedef long long lld; struct rle { int a, rpt; rle(int a_=0, int rpt_=0) : a(a_), rpt(rpt_) {} }; int N, J, R, T, rcn; vector<rle> v[2]; lld sum; int ce(int a){ return (a+R-1)/R; } void push(int ix, rle k){ if(k.rpt == 0) return; if(v[ix].empty()){ v[ix].push_back(k); return; } int last=v[ix].size()-1; if(v[ix][last].a == k.a) v[ix][last].rpt += k.rpt; else v[ix].push_back(k); } int main(){ scanf("%d%d%d%d", &N, &J, &R, &T); if(N==1){ printf("%d\n", J); return 0; } push(0, rle(J, N-1)), sum=J; int cur=0; for(int i=T; i--;){ sum += ce(v[cur][0].a); for(int j=0; j<v[cur].size(); j++){ rle r = v[cur][j]; int com = 0; if(j<v[cur].size()-1) com=v[cur][j+1].a; push(cur^1, rle(r.a, r.rpt-1)); push(cur^1, rle(r.a-ce(r.a)+ce(com), 1)); } v[cur].clear(); cur^=1; } for(int i=v[cur].size(); i--;){ for(int j=v[cur][i].rpt; j--;) printf("%d\n", v[cur][i].a); } printf("%lld\n", sum); return 0; }

Compilation message (stderr)

nectar.cpp: In function 'int main()':
nectar.cpp:32:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<v[cur].size(); j++){
                ~^~~~~~~~~~~~~~
nectar.cpp:34:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(j<v[cur].size()-1) com=v[cur][j+1].a;
       ~^~~~~~~~~~~~~~~~
nectar.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d%d", &N, &J, &R, &T);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...