제출 #693291

#제출 시각아이디문제언어결과실행 시간메모리
693291Tien_NoobTwo Antennas (JOI19_antennas)C++17
13 / 100
81 ms19596 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" using namespace std; const int N = 2e5, oo = 2e9 + 1; int n, q, h[N + 1], a[N + 1], b[N + 1]; int dp[2001][2001]; void maximize(int &a, int b) { if (a < b) { a = b; } } void read() { cin >> n; for (int i = 1; i <= n; ++ i) { cin >> h[i] >> a[i] >> b[i]; } } void sub2() { memset(dp, -1, sizeof(dp)); for (int l = 1; l <= n; ++ l) { for (int r = l + a[l]; r <= min(n, l + b[l]); ++ r) { if (r - b[r] <= l && l <= r - a[r]) { dp[l][r] = abs(h[l] - h[r]); } } } for (int lens = 2; lens <= n; ++ lens) { for (int l = 1; l + lens - 1 <= n; ++ l) { int r = l + lens - 1; maximize(dp[l][r], dp[l][r - 1]); maximize(dp[l][r], dp[l + 1][r]); } } cin >> q; while(q--) { int l, r; cin >> l >> r; cout << (dp[l][r] == oo ? -1 : dp[l][r]) << '\n'; } } void solve() { if (n <= 2000) { sub2(); return ; } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

컴파일 시 표준 에러 (stderr) 메시지

antennas.cpp: In function 'int main()':
antennas.cpp:68:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   68 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...