제출 #1205287

#제출 시각아이디문제언어결과실행 시간메모리
1205287notme비스킷 담기 (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;
}

컴파일 시 표준 에러 (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...