Submission #1066241

#TimeUsernameProblemLanguageResultExecution timeMemory
1066241Ahmed57Packing Biscuits (IOI20_biscuits)C++17
42 / 100
1004 ms16844 KiB
#include "bits/stdc++.h" using namespace std; #define int long long vector<int> A; int lim , X; 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); } 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]/2)+A[i]<X)it2++; while(it1<lol.size()||it2<lol.size()){ if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])/2+A[i]<=(lol[it2][0])/2+A[i]-X)){ nlol.push_back({(lol[it1][0])/2+A[i],lol[it1][1]}); it1++; }else{ nlol.push_back({(lol[it2][0])/2+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; } } 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:25: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]
   25 |     for(int i = 0;i<A.size();i++){
      |                   ~^~~~~~~~~
biscuits.cpp:29: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]
   29 |         while(it2<lol.size()&&(lol[it2][0]/2)+A[i]<X)it2++;
      |               ~~~^~~~~~~~~~~
biscuits.cpp:30: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]
   30 |         while(it1<lol.size()||it2<lol.size()){
      |               ~~~^~~~~~~~~~~
biscuits.cpp:30: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]
   30 |         while(it1<lol.size()||it2<lol.size()){
      |                               ~~~^~~~~~~~~~~
biscuits.cpp:31: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]
   31 |             if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])/2+A[i]<=(lol[it2][0])/2+A[i]-X)){
      |                ~~~^~~~~~~~~~~
biscuits.cpp:31: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]
   31 |             if(it1<lol.size()&&(it2==lol.size()||(lol[it1][0])/2+A[i]<=(lol[it2][0])/2+A[i]-X)){
      |                                 ~~~^~~~~~~~~~~~
biscuits.cpp:40: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]
   40 |         for(int j = 0;j<nlol.size();){
      |                       ~^~~~~~~~~~~~
biscuits.cpp:43: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]
   43 |             while(it<nlol.size()&&nlol[it][0]==nlol[j][0]){
      |                   ~~^~~~~~~~~~~~
biscuits.cpp:52: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]
   52 |     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...