제출 #562767

#제출 시각아이디문제언어결과실행 시간메모리
562767dattranxxxGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++11
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; void file() { const string FILE_NAME = "FILE_NAME"; freopen((FILE_NAME + ".inp").c_str(), "r", stdin); freopen((FILE_NAME + ".out").c_str(), "w", stdout); } const int N = 2e5 + 5; int a[N], pre[N], suf[N]; int n; int main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; vector<int> hill; a[0] = a[n+1] = -1e9; for (int i = 1; i <= n; ++i) pre[i] = pre[i-1] + max(0, a[i-1] + 1 - a[i]); for (int i = n; i; --i) suf[i] = suf[i+1] + max(0, a[i+1] + 1 - a[i]); int res = 1e9; for (int i = 1; i <= n; ++i) res = min(res, max(pre[i], suf[i])); cout << res; return 0; }

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

Main.cpp: In function 'void file()':
Main.cpp:6:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  freopen((FILE_NAME + ".inp").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen((FILE_NAME + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...