Submission #1038975

#TimeUsernameProblemLanguageResultExecution timeMemory
1038975ZicrusOvertaking (IOI23_overtaking)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #include "overtaking.h" using namespace std; typedef long long ll; vector<ll> tCur, tNxt; vector<int> s; int x, m; void init(int l, int n, vector<ll> t, vector<int> w, int x1, int m1, vector<int> s1) { s = s1; m = m1; x = x1; tCur = vector<ll>(); tNxt = vector<ll>(); vector<pair<ll, ll>> busses(n); for (int i = 0; i < n; i++) { busses[i] = {t[i], w[i]}; } sort(busses.begin(), busses.end()); for (int i = 0; i < n; i++) { ll curTime = busses[i].first; ll idealNxt = curTime + busses[i].second * (s[1] - s[0]); auto iter = lower_bound(tCur.begin(), tCur.end(), curTime); ll id = iter - tCur.begin(); ll mxNxt = id > 0 ? tNxt[id-1] : 0; ll nxt = max(idealNxt, mxNxt); if (nxt > mxNxt) { if (id < tCur.size() && curTime == tCur[id]) { tNxt[id] = nxt; } else { auto iter2 = upper_bound(tNxt.begin(), tNxt.end(), nxt); tCur.erase(iter, tCur.begin() + (iter2 - tNxt.begin())); tNxt.erase(tNxt.begin() + id, iter2); tCur.insert(iter, curTime); tNxt.insert(tNxt.begin() + id, nxt); } } } } ll arrival_time(ll y) { ll idealNxt = y + x * (s[1] - s[0]); ll id = lower_bound(tCur.begin(), tCur.end(), y) - tCur.begin(); ll mxNxt = id > 0 ? tNxt[id-1] : 0; return max(idealNxt, mxNxt); }

Compilation message (stderr)

overtaking.cpp: In function 'void init(int, int, std::vector<long long int>, std::vector<int>, int, int, std::vector<int>)':
overtaking.cpp:31:20: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             if (id < tCur.size() && curTime == tCur[id]) {
      |                 ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...