Submission #1205287

#TimeUsernameProblemLanguageResultExecution timeMemory
1205287notmePacking Biscuits (IOI20_biscuits)C++20
0 / 100
1 ms328 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long cnt[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] > 1)cnt[i+1] += cnt[i]/2; cnt[i] %= 2; } long long all = 0; for (int i = 0; i <= 64; ++ i) if(cnt[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:19:17: warning: iteration 64 invokes undefined behavior [-Waggressive-loop-optimizations]
   19 |         if(cnt[i])all ++;
      |            ~~~~~^
biscuits.cpp:18:23: note: within this loop
   18 |     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...