Submission #720387
Source Code Expand
#include <stdio.h>
#define NMAX 100002
int main(){
int ret;
int i,j,k;
int N,K;
int a[NMAX];
unsigned long long int tmp;
unsigned long long int total;
ret=scanf("%d %d",&N,&K);
for(i=1;i<=N;i++){
scanf("%d",&a[i]);
}
tmp=0;
for(i=1;i<=K;i++){
tmp += a[i];
}
total=tmp;
for(i=2;i<=(N-K+1);i++){
tmp = tmp - a[i-1] + a[K+i-1];
total += tmp;
}
printf("%lld\n",total);
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - 総和 |
| User | yab |
| Language | C (GCC 5.4.1) |
| Score | 100 |
| Code Size | 521 Byte |
| Status | AC |
| Exec Time | 24 ms |
| Memory | 512 KiB |
Compile Error
./Main.c: In function ‘main’:
./Main.c:16:11: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&a[i]);
^
Judge Result
| Set Name | sample | subtask1 | subtask2 | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 50 / 50 | 50 / 50 | ||||||
| Status |
|
|
|
| Set Name | Test Cases |
|---|---|
| sample | sample01.txt, sample02.txt |
| subtask1 | 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, sample01.txt, sample02.txt |
| subtask2 | 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00.txt | AC | 2 ms | 128 KiB |
| 01.txt | AC | 2 ms | 128 KiB |
| 02.txt | AC | 2 ms | 128 KiB |
| 03.txt | AC | 2 ms | 128 KiB |
| 04.txt | AC | 2 ms | 128 KiB |
| 05.txt | AC | 2 ms | 128 KiB |
| 06.txt | AC | 2 ms | 128 KiB |
| 07.txt | AC | 2 ms | 128 KiB |
| 08.txt | AC | 2 ms | 128 KiB |
| 09.txt | AC | 2 ms | 128 KiB |
| 10.txt | AC | 2 ms | 128 KiB |
| 11.txt | AC | 24 ms | 512 KiB |
| 12.txt | AC | 23 ms | 512 KiB |
| 13.txt | AC | 24 ms | 512 KiB |
| 14.txt | AC | 23 ms | 512 KiB |
| 15.txt | AC | 23 ms | 512 KiB |
| 16.txt | AC | 23 ms | 512 KiB |
| 17.txt | AC | 24 ms | 512 KiB |
| 18.txt | AC | 17 ms | 512 KiB |
| 19.txt | AC | 23 ms | 512 KiB |
| sample01.txt | AC | 2 ms | 128 KiB |
| sample02.txt | AC | 2 ms | 128 KiB |