제출 #696316

#제출 시각아이디문제언어결과실행 시간메모리
696316garam1732비스킷 담기 (IOI20_biscuits)C++14
0 / 100
17 ms844 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef __int128 ii; ll dp[100]; ll solve(ll x, vector<ll> a, bool full) { if(a.empty()) return dp[0] = 1; ll z = *a.rbegin(); int sz = a.size(); a.pop_back(); if(full && dp[sz]) return dp[sz]; ll q = z/x, res = 0; res += (q+1)*solve(x, a, 1); if(z % x) { ii v = (ii)(x-z%x)*(1<<(sz-1)); for(int i = (int)a.size()-1; i >= 0; i--) { if(v == 0) break; else if(v >= (ii)a[i]*(1<<i)) { v -= (ii)a[i]*(1<<i); a.pop_back(); } else { a[i] -= v/(1<<i); break; } } if(v == 0) res += solve(x, a, 0); } if(full) dp[sz] = res; return res; } long long count_tastiness(long long x, std::vector<long long> a) { for(int i = 0; i <= a.size(); i++) { dp[i] = 0; for(int j = i+1; j < a.size(); j++) { if(a[i]/x >= (1<<(j-i))-1) { a[i] += a[j]*(1<<(j-i)); a[j] = 0; } } } return solve(x, a, 0); }

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i <= a.size(); i++) {
      |                 ~~^~~~~~~~~~~
biscuits.cpp:43:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int j = i+1; j < a.size(); j++) {
      |                          ~~^~~~~~~~~~
#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...