Submission #72424

#TimeUsernameProblemLanguageResultExecution timeMemory
72424마릴린 희정 (#118)Nectar with Coconut Jelly (FXCUP3_nectar)C++17
100 / 100
1110 ms1728 KiB
#include<bits/stdc++.h> using namespace std; const int MAXK = 300; int J, R, T; pair<int, vector<int> > solve(vector<int> V) { int v = J; int t = 0; int plusdv = MAXK+1; vector<int> initial(MAXK+2, -1); initial[0] = -1; while(t < T) { while (plusdv > 0 && V[plusdv-1] <= t) --plusdv; int minusdv = (v+R-1)/R; int dv = minusdv-plusdv; //[t, T) => minusdv if(initial[minusdv] == -1) initial[minusdv] = t; int EV_end_event = T; // v - k * dv <= (minusdv-1)*R // k >= (v-(minusdv-1)*R)/dv if(dv != 0) EV_end_event = min(EV_end_event, t + (v-(minusdv-1)*R + dv-1)/dv); if(plusdv != 0) EV_end_event = min(EV_end_event, V[plusdv-1]); //EV_end_event = t+1; //printf("%d %d %d %d\n", t, v, minusdv, plusdv); v -= dv*(EV_end_event-t); t = EV_end_event; } if(initial[0] == -1) initial[0] = T; for(int i=0; i<=MAXK; ++i) { if(initial[i] == 0) break; if(initial[i+1] == -1) initial[i+1] = initial[i]; } return make_pair(v, initial); } int main() { int N; scanf("%d%d%d%d", &N, &J, &R, &T); vector<int> initial(MAXK+2, -1); initial[0] = 0; long long v = 1LL*N*J; for(int i=0; i<N-1; ++i) { int ans; tie(ans, initial) = solve(initial); //for(int i=0; i<10; ++i){int x=initial[i]; printf("%d " ,x);} //puts(""); printf("%d\n", ans); v -= ans; } printf("%lld\n", v); return 0; }

Compilation message (stderr)

nectar.cpp: In function 'int main()':
nectar.cpp:53:8: 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...