|
|
back to boardwa #5 #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n,count = 1; long long m, sum = 0; vector<long long> coll; vector<pair<long long, int>> coll1; cin >> n; while(n--) { cin >> m; coll.push_back(m); } m = coll[0]; int i = 1; if(coll.size() > 3){ for( ; i < coll.size(); ++i) { if(m <= coll[i] && count < 3) { count++; } else if( i>=3) { sum += coll[i-1]; sum += coll[i-2]; sum += coll[i-3]; coll1.push_back({sum, i-1}); sum = 0; count = 1; } m = coll[i]; } sort(coll1.begin(), coll1.end()); cout << coll1[coll1.size()-1].first << ' ' << coll1[coll1.size()-1].second << endl; } else cout << accumulate(coll.begin(), coll.end(), 0) << ' '<<'2' << endl; coll.clear(); coll1.clear(); return 0; } |
|
|