제출 #437797

#제출 시각아이디문제언어결과실행 시간메모리
437797hhhhaura선물상자 (IOI15_boxes)C++14
100 / 100
1543 ms263248 KiB
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define ceil(a, b) ((a + b - 1) / (b))
#define all(x) x.begin(), x.end()

#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

using namespace std;

#define ll long long int
#define lld long double
#define pii pair<ll, ll>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) cerr << "line " << __LINE__ << ": ", kout("[" + string(#a) + "] = ", a)
void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void kout() { cerr << endl; }
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif 
#include "boxes.h"
int n, k, l;
vector<ll> pos, dp;
void init_(int _n, int _k, int _l) {
	n = _n, k = _k, l = _l;
	pos.assign(n + 2, 0);
	dp.assign(n + 2, INF);
}
ll solve() {
	dp[0] = 0;
	deque<pii> s1, s2;
	s1.push_back({0ll, 2 * (l - pos[1])});
	s2.push_back({0ll, 0ll});
	rep(i, 1, n) {
		while(s1.size() && s1.front().first < i - k) s1.pop_front();
		while(s2.size() && s2.front().first < i - k) s2.pop_front();
		dp[i] = min(s1.front().second, s2.front().second + min((ll)l, 2 * pos[i]));
		while(s1.size() && s1.back().second >= dp[i] + 2 * (l - pos[i + 1])) s1.pop_back();
		while(s2.size() && s2.back().second >= dp[i]) s2.pop_back();
		s1.push_back({i, dp[i] + 2 * (l - pos[i + 1])});
		s2.push_back({i, dp[i]});
	}
	return dp[n];
}
ll delivery(int N, int K, int L, int p[]) {
	init_(N, K, L);
	rep(i, 0, N - 1) pos[i + 1] = p[i];
	return solve(); 
}

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

boxes.cpp:4: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    4 | #pragma loop-opt(on)
      | 
boxes.cpp:24:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
boxes.cpp:24:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   24 | void vprint(auto L, auto R) { while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
#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...