Submission #1066244

#TimeUsernameProblemLanguageResultExecution timeMemory
1066244Ahmed57Packing Biscuits (IOI20_biscuits)C++17
9 / 100
1056 ms525864 KiB
#include "bits/stdc++.h" using namespace std; #define int long long vector<int> A; int lim , X; long long inf = 1.1e18; long long count_tastiness(long long x,vector<long long> a){ A.clear(); for(int i = 0;i<a.size();i++)A.push_back(a[i]); int k = A.size(); int ans = 0; for(int i = 0;i<A.size();i++){ ans/=2; ans+=A[i]; } while(ans>=x){ ans/=2; A.push_back(0); } for(int i = 1;i<A.size();i++){ A[i]*=(1ll<<i); } k = A.size(); lim = k; X = x; vector<array<int,2>> lol; lol.push_back({0,1}); for(int i = 0;i<A.size();i++){ vector<array<int,3>> nlol; int it1 = 0; int it2 = 0; while(it2<lol.size()&&(lol[it2][0])+A[i]<X)it2++; while(it1<lol.size()||it2<lol.size()){ if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])+A[i]<=(lol[it2][0])+A[i]-X)){ nlol.push_back({(lol[it1][0])+A[i],lol[it1][1]}); it1++; }else{ nlol.push_back({(lol[it2][0])+A[i]-X,lol[it2][1]}); it2++; } } lol.clear(); for(int j = 0;j<nlol.size();){ int it = j; int sum = 0; while(it<nlol.size()&&nlol[it][0]==nlol[j][0]){ sum+=nlol[it][1]; it++; } lol.push_back({nlol[j][0],sum}); j = it; } X*=2; X = min(X,inf); } long long all = 0; for(int i = 0;i<lol.size();i++){ all+=lol[i][1]; } return all; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:9:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 0;i<a.size();i++)A.push_back(a[i]);
      |                   ~^~~~~~~~~
biscuits.cpp:12:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i = 0;i<A.size();i++){
      |                   ~^~~~~~~~~
biscuits.cpp:20:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 1;i<A.size();i++){
      |                   ~^~~~~~~~~
biscuits.cpp:28:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0;i<A.size();i++){
      |                   ~^~~~~~~~~
biscuits.cpp:32:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         while(it2<lol.size()&&(lol[it2][0])+A[i]<X)it2++;
      |               ~~~^~~~~~~~~~~
biscuits.cpp:33:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         while(it1<lol.size()||it2<lol.size()){
      |               ~~~^~~~~~~~~~~
biscuits.cpp:33:34: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         while(it1<lol.size()||it2<lol.size()){
      |                               ~~~^~~~~~~~~~~
biscuits.cpp:34:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])+A[i]<=(lol[it2][0])+A[i]-X)){
      |                ~~~^~~~~~~~~~~
biscuits.cpp:34:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])+A[i]<=(lol[it2][0])+A[i]-X)){
      |                                 ~~~^~~~~~~~~~~~
biscuits.cpp:43:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int j = 0;j<nlol.size();){
      |                       ~^~~~~~~~~~~~
biscuits.cpp:46:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             while(it<nlol.size()&&nlol[it][0]==nlol[j][0]){
      |                   ~~^~~~~~~~~~~~
biscuits.cpp:57:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i = 0;i<lol.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...