Submission #4023114


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e5 + 10;
pair<ll, double> q[MAXN];
#define dec ruiuiehrrefrf
int n, maxv, t, v, l = 1, r = 0;
ll dec, sum = 0;
double tem = 0;

int main()
{
	scanf("%d%d", &n, &maxv);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d%d", &t, &v);
		while (sum + v > maxv)
		{
			dec = min(q[l].first, sum + v - maxv);
			q[l].first -= dec;
			sum -= dec;
			tem -= q[l].second * dec;
			if (!q[l].first) l++;
		}
		sum += v;
		tem += 1ll * t * v;
		q[++r] = make_pair(v, t);
		for (; l < r && q[r].second < q[r - 1].second; --r)
		{
			q[r - 1].second = (q[r].second * q[r].first + q[r - 1].second * q[r - 1].first) / (q[r].first + q[r - 1].first);
			q[r - 1].first += q[r].first;
		}
		printf("%.7f\n", tem / maxv);
	}
}

Submission Info

Submission Time
Task F - Dam
User FFjet
Language C++14 (GCC 5.4.1)
Score 900
Code Size 821 Byte
Status AC
Exec Time 602 ms
Memory 16896 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &maxv);
                          ^
./Main.cpp:16:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &t, &v);
                        ^

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 1 ms 256 KB
00-01.txt AC 1 ms 256 KB
00-02.txt AC 1 ms 256 KB
01-00.txt AC 583 ms 16000 KB
01-01.txt AC 602 ms 9088 KB
01-02.txt AC 576 ms 16256 KB
01-03.txt AC 576 ms 12672 KB
01-04.txt AC 600 ms 8960 KB
01-05.txt AC 579 ms 16000 KB
01-06.txt AC 602 ms 9088 KB
01-07.txt AC 582 ms 16512 KB
01-08.txt AC 577 ms 12672 KB
01-09.txt AC 597 ms 8960 KB
01-10.txt AC 533 ms 16896 KB
01-11.txt AC 532 ms 16896 KB
01-12.txt AC 539 ms 16896 KB
01-13.txt AC 542 ms 16896 KB