(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #424200

#TimeUsernameProblemLanguageResultExecution timeMemory
424200ApiramPacking Biscuits (IOI20_biscuits)C++14
100 / 100
18 ms1328 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; long long count_tastiness(long long x, std::vector<long long> a) { int64_t counts =1; /*int64_t covered = 0; for (int64_t i =0;i<n;++i){ int64_t temp = pow(2,i)*arr[i]; counts+=(covered - temp)/pow(2,i); covered = max(covered,temp); }*/ vector<int64_t>arr(61,0); int64_t sum=0; for (int64_t i =0;i<a.size();++i){arr[i]=a[i];sum+=1LL<<i;} for (int64_t i =1;i<=60;++i){ arr[i]+=arr[i-1]/2; } vector<int64_t>dp(62,0); dp[0]=1; a.resize(62,0); for (int i =0;i<60;++i){ if (arr[i]<x){ dp[i+1]=dp[i]; continue; } int64_t temp =(arr[i]-a[i])/2; dp[i+1]+=dp[i]; int64_t temp2 = max(x - a[i],0LL)*2; for (int j =i-1;j>=0;--j){ if (arr[j]-temp2>=x){dp[i+1]+=dp[j]; temp2=max(0LL,x-a[j]+temp2)*2; } else temp2=max(0LL,temp2-a[j])*2; //how to check whether it is possible to get this bit ?? } if (temp2==0){ dp[i+1]++; } } return dp[60]; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for (int64_t i =0;i<a.size();++i){arr[i]=a[i];sum+=1LL<<i;}
      |                    ~^~~~~~~~~
biscuits.cpp:26:11: warning: unused variable 'temp' [-Wunused-variable]
   26 |   int64_t temp =(arr[i]-a[i])/2;
      |           ^~~~
biscuits.cpp:5:10: warning: unused variable 'counts' [-Wunused-variable]
    5 |  int64_t counts =1;
      |          ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...