답안 #307724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
307724 2020-09-29T08:30:15 Z CodePlatina 비스킷 담기 (IOI20_biscuits) C++14
0 / 100
1 ms 384 KB
#include "biscuits.h"
#include <vector>
#include <algorithm>
#include <utility>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss
#include <iostream>

using namespace std;

long long count_tastiness(long long x, vector<long long> a)
{
    int k = a.size();
    vector<long long> b(k); b[0] = a[0];
    for(int i = 1; i < k; ++i) b[i] = b[i - 1] + (a[i] << i);
    for(int i = 0; i < k; ++i) b[i] /= x;
    for(int i = 0; i < k; ++i) if(b[i] >= (1ll << i + 1)) b[i] = (1ll << i + 1) - 1;

    vector<pll> V; V.push_back({(long long)1e18, 1});
    for(int i = k - 1; i >= 0; --i)
    {
        vector<pll> _V;
        for(auto x : V)
        {
            x.ff = min(x.ff, b[i]);
            if(x.ff >= (1ll << i)) _V.push_back({(1ll << i) - 1, x.ss}), _V.push_back({x.ff - (1ll << i), x.ss});
            else _V.push_back(x);
        }
        sort(_V.begin(), _V.end());
        V.clear();
        for(auto x : _V)
        {
            if(V.size() && V.back().ff == x.ff) V.back().ss += x.ss;
            else V.push_back(x);
        }
//        cout << i << endl;
//        for(auto x : V) cout << x.ff << ' ' << x.ss << endl;
    }

    return V[0].ss;
}

Compilation message

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:23:53: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   23 |     for(int i = 0; i < k; ++i) if(b[i] >= (1ll << i + 1)) b[i] = (1ll << i + 1) - 1;
      |                                                   ~~^~~
biscuits.cpp:23:76: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   23 |     for(int i = 0; i < k; ++i) if(b[i] >= (1ll << i + 1)) b[i] = (1ll << i + 1) - 1;
      |                                                                          ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -