Submission #1081939

#TimeUsernameProblemLanguageResultExecution timeMemory
1081939faricaRadio Towers (IOI22_towers)C++17
4 / 100
4042 ms5676 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n,sub1=1,idx=0; vector<int> h; void init(int N, vector<int> H) { h.clear(); sub1 = 1; n = N; for(auto x : H) h.push_back(x); int ok=1; for(int i=0; i<H.size()-1; i++) { if(ok and H[i] > H[i+1]) { ok=0; idx = i; } if(!ok and H[i] < H[i+1]) sub1=0; } } int max_towers(int L, int R, int D) { if(sub1) { if(idx > L and idx < R and (h[L]+D) <= h[idx] and (h[R]+D) <= h[idx]) return 2; else return 1; } int ans=0; set<int>s; map<int,int>m; s.insert(max(h[L],h[L+1])); m[max(h[L], h[L+1])] = 1; for(int i=L+2; i<=R; i++) { auto it = s.lower_bound(h[i]+D); int new_ans = 0; if(it != s.end()) new_ans = m[*it]+1; m[h[i]] = ans; while(!s.empty() && *(s.begin()) < h[i]) s.erase(s.begin()); s.insert(h[i]); ans = max(ans, new_ans); } return ans; }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<H.size()-1; i++) {
      |                  ~^~~~~~~~~~~
#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...