Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- int n, t;
- cin >> n >> t;
- long long mx = 0, prefixSum = 0;
- int previous = 0;
- for (int i = 1; i <= n; ++i) {
- int current; cin >> current;
- int movesLeft = t-i+2;
- if (movesLeft <= 0) break;
- mx = max(mx, prefixSum + ((movesLeft/2)+1LL)*previous + ((movesLeft+1LL)/2)*current);
- prefixSum += previous;
- previous = current;
- }
- cout << mx << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement