답안 #720613

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720613 2023-04-08T16:01:28 Z n1k Roller Coaster Railroad (IOI16_railroad) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

#define ll long long
#define vt vector
#define pb push_back
#define ar array
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()

using namespace std;

/*
 1. simplify
 2. add new elements
 3. brute force solution
 4. optimize
 5. start implementing
*/

// --- templates ---
// --- code ---

ll plan_roller_coaster(int n, vt<int> s, vt<int> t){
	set<ar<int, 2>> a;
	for(int i = 0; i < n; i++){
		a.insert({t[i], s[i]});
	}
	/*
	pick largest exit speed
	search for largest exit <= entry speed
	*/

	//auto [exit, entry] = *(--a.end());
	auto arr = *(--a.end());
	int exit = arr[0], entry = arr[1];
	a.erase(--a.end());
	while (sz(a)){
		auto it = a.lower_bound({entry + 1});
		if(it == a.begin()){
			return 1;
		}
		it--;
		arr = *it;
		exit = arr[0], entry = arr[1];

		a.erase(it);
	}
	return 0;
}

Compilation message

railroad.cpp: In function 'long long int plan_roller_coaster(int, std::vector<int>, std::vector<int>)':
railroad.cpp:35:6: warning: variable 'exit' set but not used [-Wunused-but-set-variable]
   35 |  int exit = arr[0], entry = arr[1];
      |      ^~~~
/usr/bin/ld: /tmp/ccnmorQ5.o: in function `main':
grader.cpp:(.text.startup+0xf4): undefined reference to `plan_roller_coaster(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status