제출 #133065

#제출 시각아이디문제언어결과실행 시간메모리
133065ckodser선물상자 (IOI15_boxes)C++14
20 / 100
65 ms78840 KiB
#include "boxes.h" #include<bits/stdc++.h> #define ll long long #define F first #define S Second #define pb push_back #define pii pair<ll,ll> #define mp make_pair using namespace :: std; const ll maxn=1e7+500; const ll inf=1e17+900; ll sagh(ll n,ll k){return (n/k)+(n%k!=0);} ll dp[maxn]; long long delivery(int n, int k, int L, int p[]) { fill(dp,dp+maxn,inf); ll u=n%k; if(k==n)u=n; for(ll i=0;i<=u;i++){ vector<ll> l,r,vec; l.reserve(n/k+2); r.reserve(n/k+2); for(ll j=i+k-1;j<n;j+=k){ l.pb(2*p[j]); } ll ii=u-i; ll cnt=1; for(ll j=n-ii-k;j>=0;j-=k){ r.pb(2*(L-p[j])); } ll ct=0; if(i)ct+=2*p[i-1]; if(ii)ct+=2*(L-p[n-ii]); for(auto v:l)vec.pb(v); for(auto v:r)vec.pb(v); sort(vec.begin(),vec.end()); ll pr=0; for(ll j=0;j<vec.size();j++){ dp[j*k+u]=min(dp[j*k+u],ct+pr); pr+=vec[j]; } dp[vec.size()*k+u]=min(dp[vec.size()*k+u],ct+pr); } ll ans=sagh(n,k)*L; for(ll i=0;i*k<=n;i++){ ans=min(ans,dp[n-i*k]+L*i); } return ans; }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:44:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(ll j=0;j<vec.size();j++){
             ~^~~~~~~~~~~
boxes.cpp:32:5: warning: unused variable 'cnt' [-Wunused-variable]
  ll cnt=1;
     ^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...