Submission #487524

#TimeUsernameProblemLanguageResultExecution timeMemory
487524maks007Maxcomp (info1cup18_maxcomp)C++14
15 / 100
336 ms320 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; if(n == 1) { vector <int> a(m); for(int i = 0; i < m; i ++) cin >> a[i]; int ans = INT_MIN; for(int i = 0; i < m; i ++) { for(int end = i; end < m; end ++) { ans = max(ans, *max_element(a.begin() + i, a.begin() + end) - *min_element(a.begin() + i, a.begin() + end) - (end - i)); // cout << *max_element(a.begin() + i, a.begin() + end) << " " << *min_element(a.begin() + i, a.begin() + end) << endl; } } cout << ans; } } int main() { ios::sync_with_stdio(0); cin.tie(0); int Q = 1; //cin >> Q; while (Q --) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...