제출 #1179511

#제출 시각아이디문제언어결과실행 시간메모리
1179511gyg송신탑 (IOI22_towers)C++20
11 / 100
4099 ms2284 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; #define arr array #define vec vector const int N = 1e5 + 5; int n; arr<int, N> h; void init(int _n, vec<int> _h) { n = _n; for (int i = 1; i <= n; i++) h[i] = _h[i - 1]; } int s, f, d; arr<int, N> lf, rg; void prp_cmp() { for (int i = 1; i <= n; i++) { lf[i] = 1, rg[i] = n; for (int j = i - 1; j >= 1; j--) { if (h[j] >= h[i] + d) { lf[i] = j; break; } } for (int j = i + 1; j <= n; j++) { if (h[j] >= h[i] + d) { rg[i] = j; break; } } } // for (int i = 1; i <= n; i++) { // cout << i << ": " << lf[i] << " " << rg[i] << '\n'; // } } arr<int, N> dp; void dp_cmp() { for (int i = s; i <= f; i++) { dp[i] = 1; for (int j = s; j <= i - 1; j++) { if (j < lf[i] && i > rg[j]) { dp[i] = max(dp[i], dp[j] + 1); } } } } int max_towers(int _s, int _f, int _d) { s = _s + 1, f = _f + 1, d = _d; prp_cmp(); dp_cmp(); int ans = 0; for (int i = s; i <= f; i++) ans = max(ans, dp[i]); 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...