Submission #72834

#TimeUsernameProblemLanguageResultExecution timeMemory
72834tlwpdusNectar with Coconut Jelly (FXCUP3_nectar)C++11
15 / 100
2089 ms282196 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll n, j, r, t; ll whe[100100]; ll rem[100100]; ll arr[100100]; ll pre[100100]; ll INF = 1e9; vector<int> lis[300100]; ll divi(ll a, ll b) {return (a+b-1)/b;} ll tim(int idx) { return arr[idx]==arr[idx-1]?INF:divi(rem[idx]-(arr[idx]-1)*r,arr[idx]-arr[idx-1]); } void upd(int idx, ll cur) { rem[idx] -= (arr[idx]-pre[idx-1])*(cur-whe[idx]); whe[idx] = cur; if (tim(idx)+cur<=t) { //printf("%lld : %d\n",tim(idx)+cur,idx); lis[tim(idx)+cur].push_back(idx); } } ll tmp[100100]; int main() { int i; scanf("%lld%lld%lld%lld",&n,&j,&r,&t); for (i=1;i<=n;i++) rem[i] = j, pre[i] = arr[i] = divi(j,r); lis[tim(1)].push_back(1); for (i=1;i<=t;i++) { //printf("%d!\n",i); for (int j=0;j<lis[i].size();j++) { int v = lis[i][j]; //printf(" %d!\n",v); rem[v] -= (arr[v]-pre[v-1])*(i-whe[v]); whe[v] = i; //printf("%d, %lld!\n",v,rem[v]); if (arr[v]!=divi(rem[v],r)) { arr[v] = divi(rem[v],r); upd(v,i); if (v!=n) upd(v+1,i); } } for (int &v : lis[i]) { pre[v] = arr[v]; } } ll sum = j*n; for (i=1;i<n;i++) { sum -=rem[i]-(arr[i]-arr[i-1])*(t-whe[i]); printf("%lld\n",rem[i]-(arr[i]-arr[i-1])*(t-whe[i])); } printf("%lld\n",sum); return 0; }

Compilation message (stderr)

nectar.cpp: In function 'int main()':
nectar.cpp:40:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j=0;j<lis[i].size();j++) {
                      ~^~~~~~~~~~~~~~
nectar.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld%lld",&n,&j,&r,&t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...