답안 #72832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72832 2018-08-27T03:58:31 Z tlwpdus 코코넛 젤리 음료수 (FXCUP3_nectar) C++11
0 / 100
11 ms 7460 KB
#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

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);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 11 ms 7460 KB Output is correct
4 Incorrect 10 ms 7460 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7416 KB Output is correct
2 Correct 10 ms 7416 KB Output is correct
3 Correct 11 ms 7460 KB Output is correct
4 Incorrect 10 ms 7460 KB Output isn't correct
5 Halted 0 ms 0 KB -