제출 #957480

#제출 시각아이디문제언어결과실행 시간메모리
957480AcanikolicGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #define pb push_back #define F first #define S second #define int long long using namespace std; const int N = 1e5 + 10; const int mod = 1e9 + 7; const int inf = 2e9 + 1; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; vector<int>a(n + 1),pref(n + 1),suf(n + 1); int mx = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; if(i > 1) { int diff = a[i - 1] - a[i] + 1; pref[i] = pref[i - 1] + max(0ll,diff); } } for(int i = n - 1; i >= 1; i--) { int diff = a[i + 1] - a[i] + 1; suf[i] = suf[i + 1] + max(0ll,diff); } int res = inf; for(int i = 1; i <= n; i++) res = min(res,max(pref[i],suf[i])); cout << res; return 0; }

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

Main.cpp: In function 'int main()':
Main.cpp:27:6: warning: unused variable 'mx' [-Wunused-variable]
   27 |  int mx = 0;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...