(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 #602111

#TimeUsernameProblemLanguageResultExecution timeMemory
602111yutabiPacking Biscuits (IOI20_biscuits)C++14
100 / 100
20 ms1236 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; ll MAX_INT=1000000000000000000; long long count_tastiness(long long x, std::vector<long long> a) { ll pwr2[61]; pwr2[0]=1; for(int i=1;i<61;i++) { pwr2[i]=pwr2[i-1]*2; } while(a.size()<61) { a.pb(0); } ll ans=0; ll sum=0; vector <ll> sums; for(int i=0;i<61;i++) { sum+=pwr2[i]*a[i]; sums.pb(sum); } sum=0; vector <ll> res; for(int i=0;i<61;i++) { sum+=pwr2[i]*a[i]; if(pwr2[i]*x>MAX_INT) { break; } if(sum>=pwr2[i]*x) { ll nw_sum=sum-pwr2[i]*x; ll nw_res=1; if(i!=0) { nw_res=res.back()+1; } for(int j=i-1;j>=0;j--) { nw_sum=min(sums[j],nw_sum); if(nw_sum>=x*pwr2[j]) { if(j==0) { nw_res++; } else { nw_res+=res[j-1]+1; } nw_sum-=x*pwr2[j]; } } res.pb(nw_res); } else { if(i==0) { res.pb(0); } else { res.pb(res.back()); } } } for(int i=0;i<res.size();i++) { ans+=res[i]; } /*for(int i=0;i<res.size();i++) { printf("%lld ",res[i]); } printf("\n");*/ return res.back()+1; } /* - 1 8 1 2 11 2 2 1 13 4 2 1 1 6 8 2 1 1 2 2 16 2 1 1 2 0 1 16 2 1 1 0 1 1 8 0 0 0 1 1 1 1 */

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:107:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  107 |  for(int i=0;i<res.size();i++)
      |              ~^~~~~~~~~~~
#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...