Submission #72832

#TimeUsernameProblemLanguageResultExecution timeMemory
72832tlwpdusNectar with Coconut Jelly (FXCUP3_nectar)C++11
0 / 100
11 ms7460 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) lis[tim(idx)+cur].push_back(idx); } 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++) { for (int &v : lis[i]) { 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:31: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...