Submission #4031339
Source Code Expand
#include <string> #include <vector> #include <sstream> #include <iostream> #include <algorithm> #include <map> #include <list> #include <set> #include <numeric> #include <queue> #include <stack> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <cstring> #include <climits> #include <cfloat> #include <ctime> #include <complex> #include <cassert> #include <array> #include <bitset> #include <unordered_map> #include <random> using namespace std; typedef long long LL; typedef pair<double,LL> P; int N; LL L; int main() { cout.precision(17); scanf("%d%lld",&N,&L); double sum=0; LL sumv=0; deque<P> q; for(int i=0;i<N;i++){ double t; LL v; scanf("%lf%lld",&t,&v); sum+=t*v; sumv+=v; while(q.size()&&q.back().first>t&&v<L){ //cerr << t << ", " << v << endl; if(q.back().second+v>=L){ t=(v*t+(L-v)*q.back().first)/L; q.back().second-=L-v; v=L; } else{ auto v2=v+q.back().second; t=(v*t+q.back().second*q.back().first)/v2; v=v2; q.pop_back(); } } //cerr << t << ", " << v << endl; q.push_back(P(t,v)); while(sumv>L){ if(sumv-q.front().second>=L){ sumv-=q.front().second; sum-=q.front().first*q.front().second; q.pop_front(); } else{ LL d=sumv-L; sumv-=d; sum-=q.front().first*d; q.front().second-=d; } } printf("%.9lf\n",sum/L); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Dam |
User | kenimo |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 1469 Byte |
Status | AC |
Exec Time | 704 ms |
Memory | 18192 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:35:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%lld",&N,&L); ^ ./Main.cpp:42:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lf%lld",&t,&v); ^
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 | 683 ms | 13568 KB |
01-01.txt | AC | 704 ms | 9984 KB |
01-02.txt | AC | 672 ms | 13696 KB |
01-03.txt | AC | 676 ms | 11236 KB |
01-04.txt | AC | 697 ms | 9856 KB |
01-05.txt | AC | 680 ms | 13568 KB |
01-06.txt | AC | 700 ms | 9984 KB |
01-07.txt | AC | 680 ms | 13824 KB |
01-08.txt | AC | 677 ms | 11236 KB |
01-09.txt | AC | 700 ms | 9984 KB |
01-10.txt | AC | 636 ms | 18192 KB |
01-11.txt | AC | 638 ms | 18192 KB |
01-12.txt | AC | 643 ms | 18192 KB |
01-13.txt | AC | 651 ms | 18192 KB |