제출 #1056190

#제출 시각아이디문제언어결과실행 시간메모리
1056190Forested송신탑 (IOI22_towers)C++17
11 / 100
4080 ms1744 KiB
#include <bits/stdc++.h> using namespace std; using i32 = int; using i64 = long long; template <typename T> using V = vector<T>; template <typename T> using VV = V<V<T>>; template <typename T> using VVV = V<V<V<T>>>; template <typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; } template <typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; } #define OVERRIDE4(a, b, c, d, ...) d #define REP2(i, n) for (i32 i = 0; i < (i32)(n); ++i) #define REP3(i, l, r) for (i32 i = (i32)(l); i < (i32)(r); ++i) #define REP(...) OVERRIDE4(__VA_ARGS__, REP3, REP2)(__VA_ARGS__) #define PER2(i, n) for (i32 i = (i32)(n)-1; i >= 0; --i) #define PER3(i, l, r) for (i32 i = (i32)(r)-1; i >= (i32)(l); --i) #define PER(...) OVERRIDE4(__VA_ARGS__, PER3, PER2)(__VA_ARGS__) #define ALL(x) begin(x), end(x) #define LEN(x) (i32) size(x) void dbg(i32 x) { cerr << x; } void dbg(i64 x) { cerr << x; } template <typename T, typename U> void dbg(pair<T, U> p) { cerr << '(' << p.first << ", " << p.second << ')'; } template <typename T> void dbg(V<T> arr) { cerr << '['; REP(i, LEN(arr)) { if (i) { cerr << ", "; } dbg(arr[i]); } cerr << ']'; } void debug() { cerr << '\n'; } template <typename Head, typename... Tail> void debug(Head head, Tail... tail) { dbg(head); cerr << ", "; debug(tail...); } #ifdef DEBUGF #define DBG(...) \ do { \ cerr << #__VA_ARGS__ << " : "; \ debug(__VA_ARGS__); \ } while (false) #else #define DBG(...) (void)0 #endif #include "towers.h" i32 n; V<i32> h; void init(i32 _n, V<i32> _h) { n = _n; h = _h; } i32 max_towers(i32 l, i32 r, i32 d) { ++r; V<i32> g(begin(h) + l, begin(h) + r); i32 m = r - l; V<i32> dp(m, 1); REP(i, m) { i32 curx = -1; REP(j, i + 1, m) { if (curx - d >= g[j]) { chmax(dp[j], dp[i] + 1); } if (g[j] - d >= g[i]) { chmax(curx, g[j]); } } } i32 ans = *max_element(ALL(dp)); 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...