Submission #844076

#TimeUsernameProblemLanguageResultExecution timeMemory
844076ogkostyaOvertaking (IOI23_overtaking)C++17
65 / 100
3567 ms18012 KiB
#include "overtaking.h" #include <algorithm> #include <utility> std::vector<std::vector<std::pair<long long, long long>>> SS(1001, std::vector<std::pair<long long, long long>>()); struct sort1 { inline bool operator() (const std::pair<long long, int>& a, const std::pair<long long, int>& b) { if (a.first == b.first) return a.second < b.second; return a.first < b.first; } }; struct sort2 { inline bool operator() (const std::pair<long long, long long>& a, const std::pair<long long, long long>& b) { return a.first < b.first; } }; int _M; std::vector<int> _S; int _X; void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S) { _X = X; _M = M; _S = S; std::vector<std::pair<long long, int>> TW; TW.reserve(N); for (int i = 0; i < N; i++) { if (W[i] < X) continue; TW.push_back(std::make_pair(T[i], W[i])); } std::sort(TW.begin(), TW.end(), sort1()); for (int j = 1; j < M; j++) { std::sort(TW.begin(), TW.end(), sort1()); long long mb = 0; for (int i = 0; i < TW.size(); i++) { long long a = TW[i].first; long long b = a + 1LL * (_S[j] - _S[j - 1]) * TW[i].second; if (b < mb) b = mb; if (SS[j].size() == 0 || SS[j].back().second != b) { SS[j].push_back(std::make_pair(a, b)); } TW[i].first = b; if (b > mb) mb = b; a = b; } } } long long arrival_time(long long Y) { long long a = Y; for (int j = 1; j < _M; j++) { long long b = a + 1LL * (_S[j]-_S[j-1]) * _X; if (SS[j].size() > 0 && SS[j][0].first < a) { int l = 0, r = SS[j].size(); while (l < r) { int m = (l + r + 1) / 2; if (m == SS[j].size()) { break; } else if (SS[j][m].first < a) { l = m; } else { r = m - 1; } } if (l < SS[j].size() && b < SS[j][l].second) b = SS[j][l].second; } a = b; } return a; }

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:52:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for (int i = 0; i < TW.size(); i++)
      |                         ~~^~~~~~~~~~~
overtaking.cpp: In function 'long long int arrival_time(long long int)':
overtaking.cpp:87:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |                 if (m == SS[j].size())
      |                     ~~^~~~~~~~~~~~~~~
overtaking.cpp:101:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  101 |             if (l < SS[j].size() && b < SS[j][l].second)
      |                 ~~^~~~~~~~~~~~~~
#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...