Submission #303881

# Submission time Handle Problem Language Result Execution time Memory
303881 2020-09-20T17:55:15 Z Pajaraja Packing Biscuits (IOI20_biscuits) C++17
12 / 100
12 ms 896 KB
#include "biscuits.h"
#include <bits/stdc++.h>
#define MAXN 67
using namespace std;
long long dp[MAXN],dpu[MAXN],p[MAXN];
long long count_tastiness(long long x, std::vector<long long> a)
{
    while((x<<(a.size()))<1000000000000000000LL) a.push_back(0);
    int k=a.size();
    p[0]=a[0];
    for(long long i=1;i<k;i++) p[i]=p[i-1]+(a[i]<<i);
    for(long long i=0;i<k;i++)
    {
        long long mx=(p[i]-(x<<i))/x;
        dpu[i]=0;
        if(p[i]>=(x<<i))
        {
            if(mx>=(1LL<<i)) dpu[i]=(i!=0)?dp[i-1]:1;
            else
            {
                bool fas=false;
                for(long long j=i-1;j>=0;j--) if((1LL<<j)&mx)
                {
                    dpu[i]+=(j!=0)?dp[j-1]:1;
                    long long nx=(p[j]-(x<<j))/x;
                    if(p[j]<(x<<j)) {fas=true; break;}
                    mx^=(1LL<<j);
                    if(nx<mx) {dpu[i]+=dpu[j]; fas=true; break;}
                }
                if(!fas) dpu[i]++;
            }
        }
        dp[i]=(i!=0)?dp[i-1]:1;
        dp[i]+=dpu[i];
    }
	return dp[k-1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 12 ms 896 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -