답안 #398324

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
398324 2021-05-04T07:08:29 Z Everule 비스킷 담기 (IOI20_biscuits) C++14
0 / 100
2 ms 332 KB
#include "biscuits.h"
using namespace std;
using ll = long long int;
long long count_tastiness(long long x, std::vector<long long> a) {
    const int k = 10;
    while(a.size() < k){
        a.push_back(0);
    }
    vector<ll> dp(k);
    vector<ll> pdp(k+1);
    vector<ll> psum(k+1);
    for(int i=1;i<=k;i++){
        psum[i] = psum[i-1] + a[i-1] * (1ll<<(i-1));
    }
    for(int i=0;i<k;i++){
        dp[i] = ((psum[i+1] / (1ll<<i) / x) != 0);
        ll sum = psum[i+1] - (1ll<<i) * x;
        ll mx = sum / x;
        if(dp[i] == 0){
            pdp[i+1] = pdp[i];
            continue;
        }
        mx = min(mx, (1ll<<i) - 1);
        for(int j=i-1,s=0;j>=0;--j){
            if(mx & (1ll<<j)){
                dp[i] += pdp[j];
                sum = min(sum , psum[j+1]);
                sum -= (1ll<<j) * x;
                mx ^= (1ll<<j);
                mx =  min(mx, sum/x);
                if(sum < 0) break;
                dp[i]++;
            }
        }
        pdp[i+1] = pdp[i] + dp[i];
    }
    //for(auto &x : pdp) cout<<x<<" ";
    //cout<<"\n";
    return pdp[k] + 1;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:24:23: warning: unused variable 's' [-Wunused-variable]
   24 |         for(int j=i-1,s=0;j>=0;--j){
      |                       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -