제출 #389149

#제출 시각아이디문제언어결과실행 시간메모리
389149PedroBigMan선물상자 (IOI15_boxes)C++14
100 / 100
1308 ms524288 KiB
#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<ll> p; //REP(i,0,N) {p.pb(((ll) 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; 
	vector<ll> y; 
	REP(i,0,dp2.size()) 
	{
		y.pb(K*dp2[i]-i*L);
		if(i<K) {minyet.pb(y[i]);} else {minyet.pb(min(y[i],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 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...