Submission #72424

# Submission time Handle Problem Language Result Execution time Memory
72424 2018-08-26T08:02:21 Z 마릴린 희정(#2180, gs14004, ho94949) Nectar with Coconut Jelly (FXCUP3_nectar) C++17
100 / 100
1110 ms 1728 KB
#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

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 444 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 4 ms 444 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 8 ms 492 KB Output is correct
9 Correct 4 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 440 KB Output is correct
4 Correct 2 ms 444 KB Output is correct
5 Correct 2 ms 444 KB Output is correct
6 Correct 4 ms 444 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 8 ms 492 KB Output is correct
9 Correct 4 ms 568 KB Output is correct
10 Correct 11 ms 584 KB Output is correct
11 Correct 51 ms 904 KB Output is correct
12 Correct 93 ms 1036 KB Output is correct
13 Correct 135 ms 1332 KB Output is correct
14 Correct 108 ms 1332 KB Output is correct
15 Correct 147 ms 1332 KB Output is correct
16 Correct 149 ms 1332 KB Output is correct
17 Correct 1110 ms 1332 KB Output is correct
18 Correct 120 ms 1456 KB Output is correct
19 Correct 154 ms 1580 KB Output is correct
20 Correct 158 ms 1728 KB Output is correct
21 Correct 63 ms 1728 KB Output is correct
22 Correct 151 ms 1728 KB Output is correct
23 Correct 93 ms 1728 KB Output is correct