Submission #2892609


Source Code Expand

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const ll MAX=505000;
const ll INF=0x3f3f3f3f3f3f3f;
ll N;
double L;
double v[MAX],t[MAX];
double v_sum=0,vt_sum=0;
deque<pdd> graph;
int modify(){
    pdd t1,t2,t3;
    if(graph.size()<3) return 0;
    t1=graph.front(); graph.pop_front();
    t2=graph.front(); graph.pop_front();
    t3=graph.front();
    if((t3.x-t2.x)*(t2.y-t1.y)<=(t3.y-t2.y)*(t2.x-t1.x)){
        graph.push_front(t1);
        return 1;
    }
    graph.push_front(t2); graph.push_front(t1);
    return 0;
}
int dcut(){
    pdd t1=graph.back(),t2;
    if(t1.x+v_sum>L){
        graph.pop_back();
        t2=graph.back();
        if(t2.x+v_sum<L){
            graph.push_back(make_pair(L-v_sum,(L-v_sum-t2.x)/(t1.x-t2.x)*(t1.y-t2.y)+t2.y));
            return 0;
        }
        return 1;
    }
    return 0;
}
int main(){
    scanf("%lld%lf",&N,&L);
    for(ll i=0;i<N;i++) scanf("%lf%lf",&t[i],&v[i]);
    graph.push_front(make_pair(v_sum,vt_sum));
    for(ll i=0;i<N;i++){
        v_sum+=v[i],vt_sum+=v[i]*t[i];
        graph.push_front(make_pair(-v_sum,-vt_sum));
        while(dcut());
        while(modify());
        //printf("%d\t%.10f\t%.10f\n",graph.size(),graph.back().x,graph.back().y);
        printf("%.10f\n",(graph.back().y+vt_sum)/(graph.back().x+v_sum));
    }
    return 0;
}

Submission Info

Submission Time
Task F - Dam
User x0000ai
Language C++14 (GCC 5.4.1)
Score 900
Code Size 1511 Byte
Status AC
Exec Time 754 ms
Memory 26516 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:45:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lf",&N,&L);
                           ^
./Main.cpp:46:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(ll i=0;i<N;i++) scanf("%lf%lf",&t[i],&v[i]);
                                                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 900 / 900
Status
AC × 3
AC × 17
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 2304 KB
00-01.txt AC 2 ms 2432 KB
00-02.txt AC 2 ms 2304 KB
01-00.txt AC 723 ms 21888 KB
01-01.txt AC 754 ms 18304 KB
01-02.txt AC 714 ms 21888 KB
01-03.txt AC 717 ms 20936 KB
01-04.txt AC 743 ms 18176 KB
01-05.txt AC 726 ms 21888 KB
01-06.txt AC 744 ms 18304 KB
01-07.txt AC 723 ms 22144 KB
01-08.txt AC 720 ms 20936 KB
01-09.txt AC 735 ms 18176 KB
01-10.txt AC 693 ms 26516 KB
01-11.txt AC 694 ms 26516 KB
01-12.txt AC 701 ms 26516 KB
01-13.txt AC 703 ms 26516 KB