이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define PF push_front
#define PB push_back
#define MP make_pair
#define max(a, b) ((a > b)? a : b)
#define min(a, b) ((a < b)? a : b)
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
const int N = 2e5 + 5;
const int M = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll int INF = 1e18;
/*
Problem statement:
- Each node: speed limit(s_i), exit speed(t_i)
- Edge: Track length(x)
Edge Weight: max(t_cur - s_next, 0)
Subtask 3:
- At node i, for all s_next >= t_cur, choose min/max(t_next)
*/
// Subtask 3
ll int plan_roller_coaster(vector<int> s, vector<int> t){
multiset<pair<int, int>> node; // <speed_limit, exit_speed>
for(int i = 0; i < s.size(); i++){
node.insert(MP(s[i], t[i]));
}
pair<int, int> cur = *node.begin();
node.erase(node.find(cur));
while(!node.empty()){
auto it = node.upper_bound(MP(cur.s - 1, 0));
if(it == node.end()) return 1;
cur = *it;
node.erase(node.find(cur));
}
return 0;
}
// int main(){
// ios::sync_with_stdio(false);
// cin.tie(NULL);
// // ifstream cin();
// // ofstream cout();
// int temp;
// // temp = plan_roller_coaster({1, 4, 5, 6}, {7, 3, 8, 6});
// temp = plan_roller_coaster({3, 4, 7, 4}, {2, 7, 3, 5});
// cout << temp << endl;
// }
/*
1: (3, 2)
2: (4, 7)
3: (7, 3)
4: (4, 5)
*/
컴파일 시 표준 에러 (stderr) 메시지
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:49:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int i = 0; i < s.size(); i++){
| ~~^~~~~~~~~~
# | 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... |