이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
//#include "biscuits.h"
#define ll long long
#define double long double
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005ll
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll s[65],dp[65][65],x,a[105];
ll solve(ll bit,ll nr){
if(bit==-1)return 1;
ll &val=dp[bit][nr];
if(val!=-1) {
return val;
}
ll b=s[nr]&((1ll<<(bit+1))-1);
if(b>s[bit]){
b=s[bit];
nr=bit;
}
val=0;
if((1ll<<bit)>b){
val+=solve(bit-1,nr);
}else {
val+=solve(bit-1,bit-1)+solve(bit-1,nr);
}
return val;
}
ll count_tastiness(ll X,vector<ll>A){
x=X;
memset(a,0,sizeof(a));
for(ll i=0;i<A.size();i++)
a[i]=A[i];
for(ll i=0;i<60;i++)
s[i]=(1ll<<i)*a[i];
for(ll i=1;i<60;i++)
s[i]+=s[i-1];
for(ll i=0;i<60;i++)
s[i]/=x;
for(ll i=0;i<60;i++)
s[i]=min(s[i],(1ll<<(i+1))-1);
memset(dp,-1,sizeof(dp));
return solve(59,59);
}
/*
int32_t main(){
CODE_START;
*/
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:48:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
48 | for(ll i=0;i<A.size();i++)
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |