제출 #1158086

#제출 시각아이디문제언어결과실행 시간메모리
1158086nguynGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
16 ms4952 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define F first #define S second #define pb push_back #define pii pair<int,int> const int N = 2e5 + 5; int n, a[N]; int pre[N], suf[N]; signed main(){ ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ; if (fopen("INP.INP" ,"r")) { freopen("INP.INP" ,"r" , stdin) ; freopen("OUT.OUT" , "w" , stdout) ; } cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 2; i <= n; i++) { pre[i] = pre[i - 1] + max(0ll, a[i - 1] - a[i] + 1); } for (int i = n - 1; i >= 1; i--) { suf[i] = suf[i + 1] + max(0ll, a[i + 1] - a[i] + 1); } int res = 1e18; for (int i = 1; i <= n; i++) { res = min(res, max(pre[i], suf[i])); } cout << res; }

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

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