Submission #702166

#TimeUsernameProblemLanguageResultExecution timeMemory
702166nicky4321Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
0 / 100
1 ms328 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]; void solve(){ int n; cin >> n; int mx = 0, id = 0; for(int i = 1;i <= n;i++){ cin >> a[i]; if(a[i] > mx){ mx = a[i]; id = i; } } ll ans1 = 0, ans2 = 0; for(int i = 1;i <= id;i++){ ans1 += max(0LL, a[i - 1] + 1 - a[i]); } for(int i = id;i <= n;i++){ ans2 += max(0LL, a[i + 1] + 1 - a[i]); } cout << max(ans1, ans2) << '\n'; } int main(){ IOS // CASE solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...