제출 #1055256

#제출 시각아이디문제언어결과실행 시간메모리
1055256manhlinh1501Growing Vegetables is Fun 4 (JOI21_ho_t1)C++17
100 / 100
19 ms5108 KiB
#include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 oo64 = 1e18; using pll = pair<i64, i64>; const int MAXN = 2e5 + 5; int N; i64 a[MAXN]; i64 prefix[MAXN]; i64 suffix[MAXN]; signed main() { #define TASK "code" if (fopen(TASK ".inp", "r")) { freopen(TASK ".inp", "r", stdin); freopen(TASK ".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for(int i = 1; i <= N; i++) cin >> a[i]; for(int i = 1; i <= N; i++) prefix[i] = prefix[i - 1] + max(0LL, (a[i - 1] + 1) - a[i]); for(int i = N; i >= 1; i--) suffix[i] = suffix[i + 1] + max(0LL, (a[i + 1] + 1) - a[i]); i64 ans = oo64; for(int i = 1; i <= N; i++) ans = min(ans, max(prefix[i], suffix[i])); cout << ans; return (0 ^ 0); }

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

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