Submission #1042360

#TimeUsernameProblemLanguageResultExecution timeMemory
1042360baldwinhuang1Roller Coaster Railroad (IOI16_railroad)C++14
11 / 100
28 ms10184 KiB
#include <bits/stdc++.h> using namespace std; long long plan_roller_coaster(vector<int> s, vector<int> t) { vector< pair<int, int> > st; if (s.size() <= 8) { for (int i = 0; i < s.size(); i++) { st.push_back({s[i], t[i]}); // cout << s[i] << '-' << t[i] << '\n'; } sort(st.begin(), st.end()); long long minimo = 1e18; do { long long count = 0; for (int i = 0; i < (s.size() - 1); i++) { if (st[i].second > st[i + 1].first) { count += (st[i].second - st[i + 1].first); } } // if (count == 0) { // for (auto &i: st) { // cout << i.first << '-' << i.second << ' '; // } // cout << '\n'; // } minimo = min(minimo, count); } while (next_permutation(st.begin(), st.end())); return minimo; } for (int i = 0; i < s.size(); i++) { st.push_back({s[i], t[i]}); // cout << s[i] << '-' << t[i] << '\n'; } sort(st.begin(), st.end(), [](pair<int, int> i, pair<int, int> j){return i.second <= j.first;}); bool state = true; for (int i = 0; i < (st.size() - 1); i++) { if (st[i].second > st[i + 1].first) { state = false; } } // for (auto &i: st) { // cout << i.first << '-' << i.second << ' '; // } // cout << '\n'; return state; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:9:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         for (int i = 0; i < s.size(); i++) {
      |                         ~~^~~~~~~~~~
railroad.cpp:19:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |             for (int i = 0; i < (s.size() - 1); i++) {
      |                             ~~^~~~~~~~~~~~~~~~
railroad.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
railroad.cpp:44:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i = 0; i < (st.size() - 1); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...