Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
412 B
1
Indexable
Never
#include <iostream>

using namespace std;

int a[10001]; // 10^4

int main(){
    a[0] = 0;
    int n, k, b, t, sum = 0; cin >> n >> k >> b;
    for(int i = 1; i <= n; i++){
        cin >> a[i]; sum += a[i];
        a[i] += a[i-1];
    }
    b %= n;
    t = k/n;
    k = (b+k)%n-1;
    if(b <= k) sum = sum*t + a[k] - a[b-1];
    else sum = sum*t + a[n] - a[b-1] + a[k];
    cout << sum << endl;

    return 0;
}
Leave a Comment