fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. using ll = long long ;
  4. int main() {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. freopen("BAI2.INP","r",stdin);
  8. freopen("BAI2.OUT","w",stdout);
  9. ll N, K, B;
  10. cin >> N >> K >> B;
  11. vector<ll> a(N);
  12. for (int i = 0; i < N; i++) {
  13. cin >> a[i];
  14. }
  15. ll s = 0;
  16. for (ll i = 0; i < K; i++) {
  17. ll p= (B - 1 + i) % N;
  18. s += a[p];
  19. }
  20. cout << s;
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5284KB
stdin
5 7 6
1
2
3
4
5
stdout
18