Submission #4025837


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef pair<int64_t, double> P;

int main(){
    int N, L;
    cin >> N >> L;

    deque<P> que;
    double heat = 0;
    int volume = 0;

    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 << fixed << setprecision(10) << ans << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task F - Dam
User betrue12
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1176 Byte
Status WA
Exec Time 2498 ms
Memory 18704 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 900
Status
AC × 3
AC × 11
WA × 6
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 2 ms 384 KB
00-01.txt AC 1 ms 256 KB
00-02.txt AC 1 ms 256 KB
01-00.txt WA 2498 ms 14080 KB
01-01.txt WA 2422 ms 10496 KB
01-02.txt AC 2388 ms 14080 KB
01-03.txt WA 2375 ms 13128 KB
01-04.txt AC 2401 ms 10368 KB
01-05.txt AC 2407 ms 14080 KB
01-06.txt WA 2409 ms 10496 KB
01-07.txt AC 2390 ms 14336 KB
01-08.txt WA 2357 ms 13128 KB
01-09.txt WA 2360 ms 10368 KB
01-10.txt AC 2353 ms 18704 KB
01-11.txt AC 2396 ms 18704 KB
01-12.txt AC 2390 ms 18704 KB
01-13.txt AC 2342 ms 18704 KB