Submission #9887688
Source Code Expand
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)
const int BASE = (1 << 20);
long long N, L;
long long T[1 << 19], V[1 << 19];
int cl, cr;
long double X[1 << 21], Y[1 << 21];
long double offset_x, offset_y;
int main() {
scanf("%lld%lld", &N, &L);
for (int i = 1; i <= N; i++) scanf("%lld%lld", &T[i], &V[i]);
cl = BASE; cr = BASE;
X[cr - 1] = 0; Y[cr - 1] = 0; cr++;
X[cr - 1] = L; Y[cr - 1] = 0; cr++;
for (int i = 1; i <= N; i++) {
offset_x += V[i];
offset_y += T[i] * V[i];
while (true) {
if (cr - cl >= 2 && X[cr - 2] + offset_x > 1.0L * L) { X[cr - 1] = 0; Y[cr - 1] = 0; cr--; }
else if (X[cr - 1] + offset_x > L) {
long double E = Y[cr - 2] + 1.0L * (Y[cr - 1] - Y[cr - 2]) * ((L - offset_x) - X[cr - 2]) / (X[cr - 1] - X[cr - 2]);
X[cr - 1] = L - offset_x;
Y[cr - 1] = E;
break;
}
else break;
}
while (cr - cl >= 2) {
long double a1 = (Y[cl] + offset_y) / (X[cl] + offset_x);
long double a2 = (Y[cl + 1] + offset_y) / (X[cl + 1] + offset_x);
if (a1 <= a2) { X[cl] = 0; Y[cl] = 0; cl++; }
else break;
}
cl--;
X[cl] = -offset_x;
Y[cl] = -offset_y;
printf("%.12Lf\n", 1.0L * (Y[cr - 1] + offset_y) / L);
}
return 0;
}
Submission Info
Submission Time
2020-02-03 22:02:51+0900
Task
F - Dam
User
E869120
Language
C++14 (GCC 5.4.1)
Score
900
Code Size
1272 Byte
Status
AC
Exec Time
722 ms
Memory
40192 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:15:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld", &N, &L);
^
./Main.cpp:16:62: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for (int i = 1; i <= N; i++) scanf("%lld%lld", &T[i], &V[i]);
^
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
3 ms
8448 KB
00-01.txt
AC
3 ms
8448 KB
00-02.txt
AC
3 ms
8448 KB
01-00.txt
AC
702 ms
39808 KB
01-01.txt
AC
722 ms
23808 KB
01-02.txt
AC
690 ms
39680 KB
01-03.txt
AC
694 ms
31488 KB
01-04.txt
AC
711 ms
23552 KB
01-05.txt
AC
696 ms
39808 KB
01-06.txt
AC
715 ms
23808 KB
01-07.txt
AC
698 ms
39808 KB
01-08.txt
AC
692 ms
31488 KB
01-09.txt
AC
710 ms
23552 KB
01-10.txt
AC
659 ms
40192 KB
01-11.txt
AC
658 ms
40192 KB
01-12.txt
AC
664 ms
40192 KB
01-13.txt
AC
667 ms
40192 KB