Submission #720614

#TimeUsernameProblemLanguageResultExecution timeMemory
720614n1kRoller Coaster Railroad (IOI16_railroad)C++17
0 / 100
229 ms16708 KiB
#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 --- #include "railroad.h" long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { int n = (int) s.size(); 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 (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:38:6: warning: variable 'exit' set but not used [-Wunused-but-set-variable]
   38 |  int exit = arr[0], entry = arr[1];
      |      ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...