| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1363378 | nataliaa | K개의 묶음 (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;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
