Submission #702169

#TimeUsernameProblemLanguageResultExecution timeMemory
702169nicky4321Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
100 / 100
29 ms5452 KiB
//#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #include<bits/stdc++.h> #define ll long long #define ld long double #define F first #define S second #define PB push_back #define pii pair<int, int> #define pll pair<ll, ll> #define pdd pair<double, double> #define ALL(x) x.begin(), x.end() #define SZ(x) (int)x.size() #define vi vector<int> #define vl vector<ll> #define CASE int t;cin>>t;for(int ca=1;ca<=t;ca++) #define IOS ios_base::sync_with_stdio(false); cin.tie(0); using namespace std; const int MAX = 1 << 20, MOD = 1e9 + 7; ll a[MAX], back[MAX]; void solve(){ int n; cin >> n; int mx = 0, id = 0; for(int i = 1;i <= n;i++){ cin >> a[i]; } for(int i = n;i >= 1;i--){ back[i] = back[i + 1] + max(0LL, a[i + 1] + 1 - a[i]); } ll ans = 2e18, now = 0; for(int i = 1;i <= n;i++){ now += max(0LL, a[i - 1] + 1 - a[i]); ans = min(ans, max(now, back[i])); } cout << ans << '\n'; } int main(){ IOS // CASE solve(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:25:9: warning: unused variable 'mx' [-Wunused-variable]
   25 |     int mx = 0, id = 0;
      |         ^~
Main.cpp:25:17: warning: unused variable 'id' [-Wunused-variable]
   25 |     int mx = 0, id = 0;
      |                 ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...