Submission #1081902

#TimeUsernameProblemLanguageResultExecution timeMemory
1081902faricaRadio Towers (IOI22_towers)C++17
4 / 100
4070 ms2000 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) { 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; } vector<int> dp(n+1,1); int ans=0; for(int i=2; i<n; i++) { int maksInd=0; for(int j=i-1; j>=0; --j) { if(maksInd >= h[i]+D && maksInd >= h[j]+D) dp[i] = max(dp[i], dp[j] + 1); maksInd = max(maksInd, h[j]); } ans = max(ans,dp[i]); } return ans; }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     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...