QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216493#5129. Equalising AudioMovingUp#TL 81ms4780kbC++14846b2023-10-15 19:06:142023-10-15 19:06:15

Judging History

你现在查看的是最新测评结果

  • [2023-10-15 19:06:15]
  • 评测
  • 测评结果:TL
  • 用时:81ms
  • 内存:4780kb
  • [2023-10-15 19:06:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

const int maxn = 3e5 + 10;
const int mod = 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n;
	ld x;
	cin >> n >> x;
	vector<ld> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	auto get = [&](ld mul) {
		ld sum = 0;
		for (int i = 0; i < n; i++) {
			ld a = v[i] * mul;
			a = a * a;
			sum += a;
		}

		sum /= (ld)n;
		return sum;
	};

	ld lo = 0, hi = 1;
	while (get(hi) < x) {
		hi *= 2;
	}

	for (int i = 0; i < 150; i++) {
		ld mid = (lo + hi) / 2;
		ld val = get(mid);
		if (val < x) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

	cout << setprecision(15) << fixed;
	for (int i = 0; i < n; i++) {
		cout << v[i] * lo << " ";
	}
	cout << "\n";
 	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

input:

5 6
0 1 -2 3 -4

output:

0.000000000000000 1.000000000000000 -2.000000000000000 3.000000000000000 -4.000000000000000 

result:

ok 5 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

4 1
1 3 3 7

output:

0.242535625036333 0.727606875108999 0.727606875108999 1.697749375254331 

result:

ok 4 numbers

Test #3:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

1 0
-1000000

output:

-0.000000000000000 

result:

ok found '-0.0000000', expected '-0.0000000', error '-0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3808kb

input:

1 1000000
-1000000

output:

-1000.000000000000000 

result:

ok found '-1000.0000000', expected '-1000.0000000', error '-0.0000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

1 1000000
1000000

output:

1000.000000000000000 

result:

ok found '1000.0000000', expected '1000.0000000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 81ms
memory: 4780kb

input:

100000 1000000
1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 10000...

output:

1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.000000000000000 1000.0...

result:

ok 100000 numbers

Test #7:

score: -100
Time Limit Exceeded

input:

100000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:


result: