Submission #1318082

#TimeUsernameProblemLanguageResultExecution timeMemory
1318082zahra_Growing Vegetables is Fun 4 (JOI21_ho_t1)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long bool artan(const vector<ll>&v){ vector<ll>vc = v; sort(vc.begin() , vc.end()); if(vc == v) return true; else return false; } bool azalan(const vector<ll>&v){ vector<ll>vcc = v; sort(vcc.rbegin() , vcc.rend()); if(vcc == v) return true; else return false; } bool eyni(const vector<ll>&v){ for(int i = 0 ; i < v.size() - 1; i++){ if(v[i] == v[i + 1]) return true; } return false; } int main() { int n; cin >> n; vector<ll>v(n); for(int i = 0; i < n; i++) { cin >> v[i]; } ll total = 0; set<long long>s(v.begin(), v.end()); if(s.size() == 1) { cout << n - 1 << endl; return 0; } else if(artan(v) || azalan(v)) { cout << 0 << endl; return 0; } else{ ll maks_zirve = *max_element(v.begin(), v.end()); for(int i = 0; i < n; i++) { total += min(maks_zirve - v[i], v[i]); } } cout << total << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...