| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1363378 | nataliaa | K blocks (IZhO14_blocks) | C++20 | 0 ms | 344 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n, k;
cin >> n >> k;
int a[n+1] = {};
int mx = 0, ind = 0;
for(int i = 1; i<=n; i++){
cin >> a[i];
if(a[i]>mx){
mx = a[i];
ind = i;
}
}
int ans = mx, l = 1, r = n;
k-=1;
while(k--){
if(l<ind&&r>ind){
if(a[l]<a[r]){
ans+=a[l];
ans%=1000000009;
l++;
}
else {
ans+=a[r];
ans%=1000000009;
r--;
}
}
else if(l<ind){
ans+=a[l];
ans%=1000000009;
l++;
}
else {
ans+=a[r];
ans%=1000000009;
r--;
}
}
cout << ans;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
