제출 #1226340

#제출 시각아이디문제언어결과실행 시간메모리
1226340lamlamlamGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
100 / 100
23 ms4936 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define task "sus"
const int MN = 2e5+5,inf = 1e18;
int n,a[MN],l[MN],r[MN];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.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 >> a[i];
    int cur = 0,ans = inf;
    for(int i=1; i<=n; i++) {
        if(a[i]<=a[i-1]) cur += a[i-1] - a[i] + 1;
        l[i] = cur;
    }
    cur = 0;
    for(int i=n-1; i>=1; i--){
        if(a[i]<=a[i+1]) cur += a[i+1] - a[i] + 1;
        r[i] = cur;
    }
    for(int i=1; i<=n; i++) ans = min(ans,max(l[i],r[i]));
    cout << ans;
    cerr << "\nTIME: " << clock() << '\n';
}

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

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