제출 #130936

#제출 시각아이디문제언어결과실행 시간메모리
130936antimirage선물상자 (IOI15_boxes)C++14
100 / 100
763 ms209264 KiB
#include "boxes.h" //#include "grader.cpp" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 1e7 + 5; long long dp[N], mn = 1e18; deque <pair < long long, int> > q, q2; long long delivery(int n, int k, int l, int pos[]) { memset(dp, 0x3f3f3f3f, sizeof(dp)); int j = 0; for (int i = 0; i < n; i++) { while (j < i && pos[i] * 2 <= (l - pos[j + 1]) * 2) { while (!q2.empty() && q2.back().fr > dp[j] ) q2.pop_back(); q2.push_back({dp[j], j}); j++; } while (!q2.empty() && q2.front().sc < i - k) q2.pop_front(); while (!q.empty() && (q.front().sc < i - k || q.front().sc < j) ) q.pop_front(); if (i < k) { dp[i] = min( pos[i] * 2, min( l, (l - pos[0]) * 2 ) ) * 1ll; } if (i > 0) { if (q.empty()) dp[i] = min( dp[i], q2.front().fr + min(pos[i] * 2, l) ); else if (q2.empty()) dp[i] = min( dp[i], q.front().fr ); else dp[i] = min(dp[i], min( q.front().fr, min(pos[i] * 2, l) + q2.front().fr ) ); } if (i == n - 1) return dp[n - 1]; while (!q.empty() && q.back().fr >= dp[i] + (l - pos[i + 1]) * 2) q.pop_back(); q.push_back({dp[i] + (l - pos[i + 1]) * 2, i}); } }

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

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#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...