Submission #838150

#TimeUsernameProblemLanguageResultExecution timeMemory
838150Dremix10Radio Towers (IOI22_towers)C++17
11 / 100
1405 ms2097152 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define F first #define S second #define all(x) (x).begin(),(x).end() const int N = 3e5+5; const int MOD = 1e9+7; const ll INF = 1e18+5; #ifdef dremix #define p(x) cerr<<#x<<" = "<<x<<endl; #define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<"}"<<endl; #else #define p(x) {} #define pv(x) {} #endif vector<int> arr; int n,k; void init(int N, vector<int> H) { n = N; arr = H; int i; } int max_towers(int L, int R, int D) { vector<vector<int> > dp(n,vector<int>(n,-MOD)); int i,j; for(i=0;i<n;i++){ dp[i][i] = 1; } // dp[i][j], max group size from {0,i} with the last chosen being j (j <= i) for(i=L+1;i<=R;i++){ int maxi = -MOD; for(j=i-1;j>=L;j--){ /// transition of not chosing i dp[i][j] = max(dp[i][j],dp[i-1][j]); /// transition of choosing i: /// must find k bt {j+1,i-1} that has conditions if(maxi - D >= max(arr[i],arr[j])) dp[i][i] = max(dp[i][i],dp[i-1][j] + 1); maxi = max(maxi,arr[j]); } pv(dp[i]) } int ret = 1; for(i=0;i<n;i++)ret = max(ret,dp[R][i]); return ret; }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:28:9: warning: unused variable 'i' [-Wunused-variable]
   28 |     int 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...