이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "boxes.h"
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 5000000000000000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=1000000007LL;
template<class A=ll>
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}
template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}}
ll delivery(int n, int k, int l, int pos[])
{
ll N = (ll) n; ll K = (ll) k; ll L = (ll) l; vector<int> p; REP(i,0,N) {p.pb(pos[i]);}
vector<ll> h1,h2; ll newN=0LL;
REP(i,0,N)
{
if(pos[i]==0LL) {continue;}
newN++;
if(pos[i]<=(L-1LL)/2LL) {h1.pb(pos[i]);}
else if(pos[i]>=(L+2LL)/2LL) {h2.pb(L-pos[i]);}
}
N=newN;
ll N1=h1.size(); ll N2 = h2.size(); reverse(whole(h2));
vector<ll> dp1,dp2; dp1.pb(0LL); dp2.pb(0LL);
REP(i,0,N1)
{
if(i<K) {dp1.pb(2LL*h1[i]);}
else {dp1.pb(2LL*h1[i]+dp1[i-K+1]);}
}
REP(i,0,N2)
{
if(i<K) {dp2.pb(2LL*h2[i]);}
else {dp2.pb(2LL*h2[i]+dp2[i-K+1]);}
}
vector<ll> minyet;
ll y;
REP(i,0,dp2.size())
{
y=K*dp2[i]-i*L;
if(i<K) {minyet.pb(y);} else {minyet.pb(min(y,minyet[i-K]));}
}
REP(i,dp2.size(),N+1) {if(i>=K) {minyet.pb(minyet[i-K]);} else {minyet.pb(-1LL);}}
vector<ll> f;
REP(S,0,N+1)
{
f.pb(L*((S+K-1LL)/K));
if(minyet[S]!=-1) {f[S]=min(f[S],((S*L)+minyet[S])/K);}
}
ll ans = INF;
REP(i,0,N+1)
{
if(N-i>=dp1.size()) {continue;}
ans=min(ans,f[i]+dp1[N-i]);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:86:9: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
86 | if(N-i>=dp1.size()) {continue;}
| ~~~^~~~~~~~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |