QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#186265 | #6401. Classic: N Real DNA Pots | ucup-team228# | RE | 2ms | 3688kb | C++20 | 1.4kb | 2023-09-23 15:44:21 | 2023-09-23 15:44:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
typedef long long ll;
typedef pair<int, int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
std::ostream& operator << (std::ostream& os, const vector<T>& a) {
for (const T& x : a) {
os << x << ' ';
}
return os;
}
const double INF = 1e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<int> x(n), y(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
double low = -1e10, high = 1e10;
for (int it = 0; it < 60; ++it) {
double mid = (low + high) / 2;
vector<double> a(n);
for (int i = 0; i < n; ++i) {
a[i] = y[i] - mid * x[i];
}
vector<double> dp(n + 1, INF);
dp[0] = -INF;
for (int i = 0; i < n; ++i) {
int j = upper_bound(all(dp), a[i]) - dp.begin();
dp[j] = a[i];
}
int ans = n;
while (dp[ans] > INF / 2) {
--ans;
}
if (ans >= k) {
low = mid;
} else {
high = mid;
}
}
cout.precision(15);
cout << (low + high) / 2 << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3668kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1.00000000467781
result:
ok found '-1.0000000', expected '-1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
2 2 1 1 5 3
output:
0.499999998002099
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
2 2 222640995 547139825 489207317 725361095
output:
0.668581344800967
result:
ok found '0.6685813', expected '0.6685813', error '0.0000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3664kb
input:
1000 20 545612 774435015 828317 212155588 5294705 85926095 5648835 764528941 6159263 570820268 7177330 744079287 8446124 162286636 8735551 586528841 9263030 524140841 9505706 636254627 12111352 182639083 12750780 238494418 13149143 913232250 13382784 11485121 13699797 414697815 14263990 423817548 15...
output:
3.79321045927694
result:
ok found '3.7932105', expected '3.7932105', error '0.0000000'
Test #5:
score: -100
Runtime Error
input:
1000 100 163505 684865289 2674260 837752883 2694530 150054425 2870791 236723512 3262597 800933455 3558503 905056977 4260872 45990808 4532415 268478572 5299228 546172100 6019224 12074540 6345109 747272172 6539452 449655551 7215852 676269961 9062989 769545718 9444242 874911191 10264016 341805234 10595...