Submission #4025876
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef pair<double, int64_t> P; int main(){ int N, L; cin >> N >> L; deque<P> que; double heat = 0; int volume = 0; cout << fixed << setprecision(10); for(int i=0; i<N; i++){ double t; int v; cin >> t >> v; heat += t*v; volume += v; while(volume > L){ auto p = que.front(); if(p.second <= volume-L){ heat -= p.first * p.second; volume -= p.second; que.pop_front(); }else{ heat -= p.first * (volume-L); que.front().second -= volume-L; volume = L; } } while(que.size() > 0){ auto p = que.back(); if(p.first < t){ break; }else{ t = (p.first*p.second + t*v) / (p.second + v); v += p.second; que.pop_back(); } } que.push_back({t, v}); double ans = heat / L; cout << ans << "\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Dam |
User | betrue12 |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 1189 Byte |
Status | AC |
Exec Time | 2507 ms |
Memory | 18704 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-00.txt, 00-01.txt, 00-02.txt |
All | 00-00.txt, 00-01.txt, 00-02.txt, 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-00.txt | AC | 1 ms | 256 KB |
00-01.txt | AC | 1 ms | 256 KB |
00-02.txt | AC | 1 ms | 256 KB |
01-00.txt | AC | 2389 ms | 14080 KB |
01-01.txt | AC | 2413 ms | 10496 KB |
01-02.txt | AC | 2507 ms | 14080 KB |
01-03.txt | AC | 2449 ms | 13128 KB |
01-04.txt | AC | 2374 ms | 10368 KB |
01-05.txt | AC | 2380 ms | 14080 KB |
01-06.txt | AC | 2396 ms | 10496 KB |
01-07.txt | AC | 2424 ms | 14336 KB |
01-08.txt | AC | 2399 ms | 13128 KB |
01-09.txt | AC | 2365 ms | 10368 KB |
01-10.txt | AC | 2357 ms | 18704 KB |
01-11.txt | AC | 2419 ms | 18704 KB |
01-12.txt | AC | 2436 ms | 18704 KB |
01-13.txt | AC | 2426 ms | 18704 KB |