Submission #1021972

#TimeUsernameProblemLanguageResultExecution timeMemory
1021972parsadox2Roller Coaster Railroad (IOI16_railroad)C++17
0 / 100
83 ms13764 KiB
#include "railroad.h" #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10 , inf = 1e9 + 10; int n; struct item{ int val , ty , id; }; bool cmp(item aa , item bb) { if(aa.val != bb.val) return aa.val < bb.val; return aa.ty < bb.ty; } long long plan_roller_coaster(std::vector<int> s, std::vector<int> t) { vector <item> vec; n = s.size(); for(int i = 0 ; i < n ; i++) { //cout << s[i] << " : " << t[i] << endl; vec.push_back({t[i] , 0 , i}); vec.push_back({s[i] , 1 , i}); } vec.push_back({1 , 0 , -1}); vec.push_back({inf , 1 , n}); sort(vec.begin() , vec.end() , cmp); int sum = 0 , ty = 0 , las_bad = 10 , need_to_check = -1 , ans = 0; for(int i = 0 ; i < vec.size() ; i++) { auto u = vec[i]; las_bad++; int now = (u.ty == 0 ? 1 : -1); sum += now; if(sum == 0) { if(las_bad == 2 && vec[i].id == vec[i - 1].id) ans = 69; las_bad = 0; } if(sum < 0) ans = 69; //cout << i << " " << sum << " " << u.ty << " " << now << " " << las_bad << endl; } return ans; } /* 4 1 7 4 3 5 8 6 6 */

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<item>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0 ; i < vec.size() ; i++)
      |                     ~~^~~~~~~~~~~~
railroad.cpp:32:19: warning: unused variable 'ty' [-Wunused-variable]
   32 |     int sum = 0 , ty = 0 , las_bad = 10 , need_to_check = -1 , ans = 0;
      |                   ^~
railroad.cpp:32:43: warning: unused variable 'need_to_check' [-Wunused-variable]
   32 |     int sum = 0 , ty = 0 , las_bad = 10 , need_to_check = -1 , ans = 0;
      |                                           ^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...