Submission #45048034
Source Code Expand
#include <iostream> #include <vector> using namespace std; int main(void) { int n = 0, k = 0; double ans = 0; cin >> n >> k; /* edit 2: float -> double */ vector<double> s(n + 1); for (int i = 0; i < n; i++) { double p = 0; cin >> p; s[i + 1] = s[i] + (p + 1) / 2; } for (int i = k; i <= n; i++) { /* edit 1: 上と同じループで処理すると、n + 1を含む選び方が最も大きいときに探索しきれない */ double t = s[i] - s[i - k]; if (t > ans) ans = t; } printf("%.10f\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Dice in Line |
User | coolwind0202 |
Language | C++ (GCC 9.2.1) |
Score | 400 |
Code Size | 628 Byte |
Status | AC |
Exec Time | 64 ms |
Memory | 4828 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 01.txt, 02.txt, 03.txt |
All | 01.txt, 02.txt, 03.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 6 ms | 3628 KiB |
02.txt | AC | 2 ms | 3792 KiB |
03.txt | AC | 2 ms | 3628 KiB |
10.txt | AC | 54 ms | 4664 KiB |
11.txt | AC | 48 ms | 4660 KiB |
12.txt | AC | 57 ms | 4628 KiB |
13.txt | AC | 52 ms | 4568 KiB |
14.txt | AC | 56 ms | 4828 KiB |
15.txt | AC | 2 ms | 3788 KiB |
16.txt | AC | 2 ms | 3636 KiB |
17.txt | AC | 2 ms | 3632 KiB |
18.txt | AC | 57 ms | 4656 KiB |
19.txt | AC | 56 ms | 4724 KiB |
20.txt | AC | 64 ms | 4600 KiB |