| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1300704 | KickingKun | Two Antennas (JOI19_antennas) | C++20 | 476 ms | 18296 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define bigint __int128
#define emb emplace_back
#define pb push_back
#define pii pair <int, int>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define Task ""
#define MASK(k) (1ull << k)
#define bitcnt(k) __builtin_popcount(k)
#define testBit(n, k) ((n >> k) & 1)
#define flipBit(n, k) (n ^ (1ll << k))
#define offBit(n, k) (n & ~MASK(k))
#define onBit(n, k) (n | (1ll << k))
template <class T> bool minimize(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool maximize(T &a, T b) {if (a < b) {a = b; return true;} return false;}
const int N = 2e5 + 5, lim = 60, mod = 1e9 + 7;
const ll INF = 1e18;
int n, h[N], a[N], b[N];
namespace sub2 {
const int N = 2e3 + 5;
int res[N][N];
void solve() {
memset(res, -1, sizeof res);
for (int u = 1; u <= n; u++) {
for (int v = u + a[u]; v <= min(n, u + b[u]); v++) {
if (v - b[v] <= u && u <= v - a[v])
res[u][v] = abs(h[u] - h[v]);
}
}
for (int u = n; u > 0; u--) {
for (int v = u + 1; v <= n; v++) {
maximize(res[u][v], max(res[u + 1][v], res[u][v - 1]));
}
}
int q; cin >> q;
while (q--) {
int l, r; cin >> l >> r;
cout << res[l][r] << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
if (fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++)
cin >> h[i] >> a[i] >> b[i];
sub2::solve();
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
