QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#572223#6401. Classic: N Real DNA Potszfasion#WA 1ms10084kbC++141.5kb2024-09-18 13:08:352024-09-18 13:08:36

Judging History

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

  • [2024-09-18 13:08:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:10084kb
  • [2024-09-18 13:08:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const long long N = 3e6 + 20, M = 998244353;
#define eps 1e-12
#define int long long
// #define int __int128
#define ll long long
#define all(x) x.begin(), x.end()
#define endl '\n'
#define ls (p << 1)
#define rs ((p << 1) | 1)
#define f1 first
#define pb push_back
#define f2 second
#define IOS std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0), std::cout << std::fixed << std::setprecision(2);
int n;
double x[N], y[N], a[N], b[N];
int dp[N];
int read()
{
	int x = 0, f = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9')
	{
		f = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9')
	{
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	x *= f;
	return x;
}
void write(int x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9)
		write(x / 10);
	putchar(x % 10 + '0');
}
signed main()
{
	IOS;
	int k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> x[i] >> y[i];
	double l = -1e18, r = 1e18;
	auto check = [&](double k1) -> bool
	{
		for (int i = 1; i <= n; i++)
			dp[i] = 0, a[i] = y[i] - k1 * x[i];
		int len = 0;
		for (int i = 1; i <= n; i++)
		{
			if (a[i] > b[len])
			{
				b[++len] = a[i];
			}
			else
			{
				b[lower_bound(b + 1, b + len + 1, a[i]) - b] = a[i];
			}
		}
		return len >= k;
	};
	//check(0.5);
	while (l < r - eps)
	{
		double mid = (l + r) / 2;
		if (check(mid))
			l = mid + eps * 0.01;
		else
			r = mid - eps * 0.01;
	}
	cout << l << endl;
	return false;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 3
1 2
2 4
3 3
4 1

output:

-1.00

result:

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

Test #2:

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

input:

2 2
1 1
5 3

output:

0.50

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 10084kb

input:

2 2
222640995 547139825
489207317 725361095

output:

0.67

result:

wrong answer 1st numbers differ - expected: '0.6685813', found: '0.6700000', error = '0.0014187'