| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 39772 | 14kg | Palembang Bridges (APIO15_bridge) | C++11 | 84 ms | 5108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#define N 100001
#define min2(x,y) (x<y?x:y)
using namespace std;
typedef pair<int, pair<int, int> > pip;
int n, K;
long long out;
pair<int, int> in[N];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > Q;
void f1() {
int x1 = n, x2 = 0, w = 0;
long long sum = 0, tot;
for (int i = 1; i <= n; i++) {
sum += (long long)in[i].first;
Q.push({ in[i].first,1 }), Q.push({ in[i].second,2 });
} tot = sum * 2;
while (!Q.empty()) {
sum += (long long)(Q.top().first - w)*(long long)(x2 - x1);
tot = min2(tot, sum * 2), w = Q.top().first;
if (Q.top().second == 1) x1--;
else x2++;
Q.pop();
} out += tot;
}
int main() {
// freopen("input.txt", "r", stdin);
int k, x, y;
char in_a, in_b;
scanf("%d %d ", &K, &k);
while (k--) {
scanf("%c %d %c %d ", &in_a, &x, &in_b, &y);
if (x > y) x += y, y = x - y, x -= y;
out += (long long)(y - x);
if (in_a != in_b) out++, in[++n] = { x,y };
}
if (K == 1) f1();
printf("%lld", out);
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
