#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
struct Point {
int x;
bool type;
int ind;
friend bool operator < (Point &a, Point &b) {
if (a.x != b.x) return a.x < b.x;
return a.type > b.type;
}
};
Point point[2 * MAXN];
bool used[MAXN];
int n;
long long plan_roller_coaster(vector <int> s, vector <int> t) {
n = s.size();
if (n > 0) {
for (int i = 0; i < n; i++) {
point[i * 2] = {s[i], 0, i};
point[i * 2 + 1] = {t[i], 1, i};
}
sort(point, point + 2*n);
int cnt = 0;
priority_queue <pair <int, int>, vector <pair <int, int>>, greater <pair <int, int>> > pq;
for (int i = 0; i < 2 * n; i++) {
if (point[i].type == 0) {
if (pq.empty()) return 1;
auto cur = pq.top();
pq.pop();
if (cur.second == point[i].ind) {
pq.pop();
if (pq.empty()) return 1;
pq.pop();
pq.push(cur);
}
} else {
pq.push({t[point[i].ind], point[i].ind});
}
}
return 0;
}
}
컴파일 시 표준 에러 (stderr) 메시지
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
51 | }
| ^
railroad.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
railroad_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |