Submission #1166388

#TimeUsernameProblemLanguageResultExecution timeMemory
1166388CrabCNHGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++20
40 / 100
6 ms1096 KiB
#include <bits/stdc++.h> #define task "BriantheCrab" #define int long long #define pii pair <int, int> #define fi first #define se second #define szf sizeof #define sz(s) (int)((s).size()) using namespace std; template <class T> void mini (T &t, T f) {if (t > f) t = f;} template <class T> void maxi (T &t, T f) {if (t < f) t = f;} const int maxN = 1e5 + 5; const int inf = 1e18 + 7; const int mod = 1e9 + 7; int a[maxN], b[maxN]; int l[maxN], r[maxN]; void solve () { int n; cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i]; } for (int i = 1; i < n; i ++) { b[i] = a[i + 1] - a[i]; } for (int i = 1; i < n; i ++) { l[i] = max (1 - b[i], 0LL) + l[i - 1]; } for (int i = n - 1; i >= 1; i --) { r[i] = max (1 + b[i], 0LL) + r[i + 1]; } int res = inf; for (int i = 1; i <= n; i ++) { mini (res, max (l[i - 1], r[i])); } cout << res; } signed main () { cin.tie (nullptr) -> sync_with_stdio (false); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int t = 1; //cin >> t; while (t --) { solve (); } return 0; } // thfdgb

Compilation message (stderr)

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