Submission #562766

#TimeUsernameProblemLanguageResultExecution timeMemory
562766dattranxxxGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++11
Compilation error
0 ms0 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]); for (int i = 1; i <= n; ++i) int res = 1e9; for (int i = 1; i <= n; ++i) res = min(res, max(pre[i], suf[i])); cout << res; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:24:6: warning: unused variable 'res' [-Wunused-variable]
   24 |  int res = 1e9;
      |      ^~~
Main.cpp:26:3: error: 'res' was not declared in this scope
   26 |   res = min(res, max(pre[i], suf[i]));
      |   ^~~
Main.cpp:27:10: error: 'res' was not declared in this scope
   27 |  cout << res;
      |          ^~~
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);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~