Submission #1205288

#TimeUsernameProblemLanguageResultExecution timeMemory
1205288notmePacking Biscuits (IOI20_biscuits)C++20
0 / 100
1 ms324 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long cnt[64], has[64]; long long count_tastiness(long long x, std::vector<long long> a) { int k = a.size(); for (int i = 0; i < k; ++ i) { cnt[i] = a[i]; } for (int i = 0; i < 64; ++ i) { if(cnt[i])has[i] = 1; if(cnt[i] > 1)cnt[i+1] += cnt[i]/2; cnt[i] %= 2; } long long all = 0; for (int i = 0; i <= 64; ++ i) if(has[i])all ++; long long ans = 1; for (int i = 0; i < all; ++ i) ans *= 2; return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:20:17: warning: iteration 64 invokes undefined behavior [-Waggressive-loop-optimizations]
   20 |         if(has[i])all ++;
      |            ~~~~~^
biscuits.cpp:19:23: note: within this loop
   19 |     for (int i = 0; i <= 64; ++ 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...