Submission #405859

#TimeUsernameProblemLanguageResultExecution timeMemory
405859ly20Packing Biscuits (IOI20_biscuits)C++17
0 / 100
43 ms5164 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 64; long long mc[MAXN]; bool inf(long long a, long long b) { if(log10(a) + log10(b) > 18) return true; return false; } long long count_tastiness(long long x, vector<long long> a) { int tot = 0; for(int i = 0; i < a.size(); i++) { mc[i] = a[i]; } for(int i = a.size(); i < MAXN; i++) mc[i] = 0; set <long long> s; long long cur = 0; s.insert(0); for(int i = 0; i < MAXN; i++) { int at = mc[i] * (1LL << i); cur += at; if(inf(x, (1LL << i))) continue; long long nec = x * (1LL << i); set <long long> :: iterator it = s.lower_bound(nec - cur); vector <long long> rs; while(it != s.end()) { rs.push_back(*it); it++; } for(int j = 0; j < rs.size(); j++) { s.insert(rs[j] - nec); } } return s.size(); } /*int main() { int t; scanf("%d", &t); while(t--) { long long x; int k; vector <long long> a; scanf("%d %lld", &k, &x); for(int i = 0; i < k; i++) { long long b; scanf("%lld", &b); a.push_back(b); } printf("resp == %lld\n", count_tastiness(x, a)); } return 0; } */

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i < a.size(); i++) {
      |                 ~~^~~~~~~~~~
biscuits.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j = 0; j < rs.size(); j++) {
      |                        ~~^~~~~~~~~~~
biscuits.cpp:14:6: warning: unused variable 'tot' [-Wunused-variable]
   14 |  int tot = 0;
      |      ^~~
#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...