Submission #123597

#TimeUsernameProblemLanguageResultExecution timeMemory
123597baqargamRoller Coaster Railroad (IOI16_railroad)C++14
0 / 100
131 ms13448 KiB
#include "bits/stdc++.h" #include "railroad.h" using namespace std; long long j,l,d[400005],g[100],bal; vector<pair<int,int> >v; long long plan_roller_coaster(vector<int> s, vector<int> t) { int n = (int) s.size(); for(int i=1;i<=n;i++){ v.push_back({s[i-1],i}); v.push_back({t[i-1],-i}); } sort(v.begin(),v.end()); for(int i=0;i<2*n;i++){ int id=v[i].second; int val=v[i].first; if(id>0) { id=-id; if(d[id]==0) bal--; else bal++; d[id]=1; } else { if(d[id]==0) bal++; else bal--; d[id]=1; } if(bal>0) return 0; } return 1; }

Compilation message (stderr)

railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:18:13: warning: unused variable 'val' [-Wunused-variable]
         int val=v[i].first;
             ^~~
railroad.cpp:22:20: warning: array subscript is below array bounds [-Warray-bounds]
             if(d[id]==0)
                ~~~~^
railroad.cpp:26:17: warning: array subscript is below array bounds [-Warray-bounds]
             d[id]=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...