Submission #11349364


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
long long a[100004];
int main(){
	memset(a,0,sizeof(a));
	int n,k;
	cin >> n >>k;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	long long sum=0;
	long long tmp=0;
	for(int i=0;i<k;i++){
		tmp+=a[i];
	}
	for(int i=0;i<n-k+1;i++){
		//cout << tmp <<endl;
		sum  += tmp;
		tmp = tmp- a[i] + a[i+k];
	}
	cout << sum << endl;
	return 0;
}

Submission Info

Submission Time
Task C - 総和
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 100
Code Size 396 Byte
Status
Exec Time 38 ms
Memory 1024 KB

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample01.txt, sample02.txt
subtask1 50 / 50 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, sample01.txt, sample02.txt
subtask2 50 / 50 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, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
00.txt 2 ms 1024 KB
01.txt 2 ms 1024 KB
02.txt 2 ms 1024 KB
03.txt 2 ms 1024 KB
04.txt 2 ms 1024 KB
05.txt 2 ms 1024 KB
06.txt 2 ms 1024 KB
07.txt 2 ms 1024 KB
08.txt 2 ms 1024 KB
09.txt 2 ms 1024 KB
10.txt 2 ms 1024 KB
11.txt 37 ms 1024 KB
12.txt 37 ms 1024 KB
13.txt 37 ms 1024 KB
14.txt 37 ms 1024 KB
15.txt 37 ms 1024 KB
16.txt 37 ms 1024 KB
17.txt 38 ms 1024 KB
18.txt 17 ms 1024 KB
19.txt 38 ms 1024 KB
sample01.txt 2 ms 1024 KB
sample02.txt 2 ms 1024 KB