Submission #2121224
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) #define MOD (1000000007ll) bool conccomp(int x, int y, int p, int q){ return (p*y>x*q); } int main(void){ int k,n,i; ll a[123456],t[123456],ans=0ll; fill(t,t+123456,0ll); cin >> n >> k; for(i=0; i<n; ++i){ cin >> a[i]; } for(i=0; i<n; ++i){ if(i+k>n){ break; } t[i]++; t[i+k]--; } for(i=1; i<n; ++i){ t[i] += t[i-1]; } for(i=0; i<n; ++i){ ans += (a[i]*t[i]); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 総和 |
User | ransewhale |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 575 Byte |
Status | AC |
Exec Time | 39 ms |
Memory | 2048 KB |
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.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 | 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 | AC | 2 ms | 1152 KB |
01.txt | AC | 2 ms | 1152 KB |
02.txt | AC | 2 ms | 1152 KB |
03.txt | AC | 2 ms | 1280 KB |
04.txt | AC | 2 ms | 1280 KB |
05.txt | AC | 2 ms | 1152 KB |
06.txt | AC | 2 ms | 1152 KB |
07.txt | AC | 2 ms | 1152 KB |
08.txt | AC | 2 ms | 1152 KB |
09.txt | AC | 2 ms | 1280 KB |
10.txt | AC | 2 ms | 1152 KB |
11.txt | AC | 38 ms | 2048 KB |
12.txt | AC | 38 ms | 2048 KB |
13.txt | AC | 38 ms | 2048 KB |
14.txt | AC | 38 ms | 2048 KB |
15.txt | AC | 38 ms | 2048 KB |
16.txt | AC | 38 ms | 2048 KB |
17.txt | AC | 39 ms | 2048 KB |
18.txt | AC | 18 ms | 2048 KB |
19.txt | AC | 38 ms | 2048 KB |
sample01.txt | AC | 2 ms | 1152 KB |
sample02.txt | AC | 2 ms | 1152 KB |