Submission #650879

#TimeUsernameProblemLanguageResultExecution timeMemory
650879NaimSSRadio Towers (IOI22_towers)C++17
0 / 100
447 ms2096 KiB
#include "towers.h" #include <bits/stdc++.h> #define pb push_back using namespace std; #include <vector> const int N = 100100; int cnt[N]; int h[N]; vector<int> pos; void init(int N, std::vector<int> H) { cnt[0] = (N > 1 && H[0] < H[1]); if(cnt[0])pos.pb(0); for(int i=0;i<N;i++)h[i] = H[i]; for(int i=1;i<N;i++){ cnt[i]=cnt[i-1]; if(H[i] < H[i-1]){ cnt[i]++; pos.pb(i); } } } int max_towers(int L, int R, int D) { int v = (L+1<=R && h[L] < h[L+1]); int p = upper_bound(pos.begin(),pos.end(),L) - pos.begin(); if(p == pos.size() || pos[p] > R)return 1; int qtd = cnt[R] - cnt[pos[p]-1]; if(v)qtd++; return qtd; }

Compilation message (stderr)

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(p == pos.size() || pos[p] > R)return 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...