Submission #830465

#TimeUsernameProblemLanguageResultExecution timeMemory
830465RaresFelixSnowball (JOI21_ho_t2)C++17
100 / 100
177 ms17044 KiB
#include <bits/stdc++.h> using namespace std; const int MN = 200001; const int MQ = 200001; using ll = long long; ll P[MN], A[MQ], St[MN], Dr[MN]; int n, q; vector<pair<ll, int> > Dist; int main() { cin >> n >> q; for(int i = 1; i <= n; ++i) { cin >> P[i]; St[i] = Dr[i] = -1; } for(int i = 1; i < n; ++i) { Dist.push_back(make_pair(P[i + 1] - P[i], i)); } sort(Dist.begin(), Dist.end()); ll itD = 0, st = 0, dr = 0, p = 0; for(int i = 1; i <= q; ++i) { cin >> A[i]; p += A[i]; if(p > dr) { while(itD != Dist.size() && Dist[itD].first <= st + p) { int acum = Dist[itD].second; if(St[acum + 1] == -1) St[acum + 1] = st; if(Dr[acum] == -1) Dr[acum] = Dist[itD].first - st; ++itD; } dr = p; } if(-p > st) { while(itD != Dist.size() && Dist[itD].first <= dr - p) { int acum = Dist[itD].second; if(Dr[acum] == -1) Dr[acum] = dr; if(St[acum + 1] == -1) St[acum + 1] = Dist[itD].first - dr; ++itD; } st = -p; } } for(int i = 1; i <= n; ++i) { if(St[i] == -1) St[i] = st; if(Dr[i] == -1) Dr[i] = dr; cout << St[i] + Dr[i] << "\n"; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:27:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             while(itD != Dist.size() && Dist[itD].first <= st + p) {
      |                   ~~~~^~~~~~~~~~~~~~
Main.cpp:38:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             while(itD != Dist.size() && Dist[itD].first <= dr - p) {
      |                   ~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...