제출 #1169723

#제출 시각아이디문제언어결과실행 시간메모리
1169723thelegendary08송신탑 (IOI22_towers)C++17
11 / 100
4162 ms2162688 KiB
#include "towers.h" #include<bits/stdc++.h> #define vi vector<int> #define pb push_back #define f0r(i,n) for(int i = 0; i<n; i++) #define FOR(i, k, n) for(int i = k; i<n; i++) using namespace std; int mxd = -1; int mx = 0; vi v; const int mxn = 1e5 + 5; vi tree(mxn * 4); int n; void update(int k, int x){ k += n; tree[k] = x; for(k /=2; k>=1; k/=2){ tree[k] = max(tree[k*2], tree[k*2+1]); } } int quer(int l, int r){ if(l >r)return 0; l += n; r += n; int ret = 0; while(l <= r){ if(l % 2 == 1)ret = max(ret, tree[l++]); if(r % 2 == 0)ret = max(ret, tree[r--]); r /=2; l /=2; } return ret; } void init(int N, std::vector<int> v) { ::v = v; f0r(i, N){ if(v[i] > mx){ mx = v[i]; mxd = i; } } } int max_towers(int l, int r, int d) { vi v; FOR(i, l, r+1){ v.pb(::v[i]); } int n = r - l + 1; ::n = n; f0r(i,n){ update(i, v[i]); } vector<vi> dp(n, vi(n+1)); dp[0][0] = 1; vi mx(n); mx[0] = 1; FOR(i, 1, n){ dp[i][0] = 1; FOR(j, 1, i+1){ int maxx = quer(j, i - 1) - d; if(v[j-1] <= maxx && v[i] <= maxx)dp[i][j] = mx[j-1] + 1; } f0r(j, n+1)mx[i] = max(mx[i], dp[i][j]); } // for(auto u : mx)cout<<u<<' '; // cout<<'\n'; int ans = 0; f0r(i,n)f0r(j, n+1)ans = max(ans, dp[i][j]); return ans; }
#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...