제출 #158498

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
1584982019-10-17 12:19:13maruiiPalembang Bridges (APIO15_bridge)C++14
22 / 100
83 ms4080 KiB
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
#define ff first
#define ss second
int K, N, cnt;
ll pfx[100005], sfx[100005], cost;
pii P[100005];
vector<int> x;
void f(ll *f) {
int s = 0;
priority_queue<pii, vector<pii>, greater<pii> > pq;
for (int i = 1, j = 0; i <= N; ++i) {
f[i] = f[i - 1] + 2 * max({0, P[i].ff - x[j], x[j] - P[i].ss});
pq.emplace(P[i].ff, 2);
pq.emplace(P[i].ss, 2);
s -= 2;
while (pq.size() && pq.top().ff <= x[j]) {
s += pq.top().ss;
pq.pop();
}
while (s < 0) {
f[i] += 1ll * s * (x[j + 1] - x[j]);
j++;
while (pq.size() && pq.top().ff <= x[j]) {
s += pq.top().ss;
pq.pop();
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...