QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#165740 | #6401. Classic: N Real DNA Pots | ZXG_DZXX | TL | 1979ms | 3928kb | C++17 | 1.8kb | 2023-09-05 21:22:24 | 2023-09-05 21:22:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int, int> PII;
typedef long long ll;
struct Fenwick
{
int n;
vector<ll> tr;
Fenwick(int _n) : n(_n)
{
tr.resize(n + 1);
}
void add(int x, ll v)
{
for(int i = x; i <= n; i += i & -i) tr[i] = max(tr[i], v);
}
ll query(int x)
{
ll res = 0;
for(int i = x; i >= 1; i -= i & -i) res = max(res, tr[i]);
return res;
}
};
void solve()
{
int n, m;
cin >> n >> m;
vector<int> x(n), y(n);
for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
auto check = [&](double k)
{
vector<int> dp(n);
vector<double> w(n);
for(int i = 0; i < n; i++) w[i] = y[i] - k * x[i];
vector<double> all;
for(int i = 0; i < n; i++) all.push_back(w[i]);
sort(all.begin(), all.end());
all.erase(unique(all.begin(), all.end()), all.end());
auto find = [&](double x)
{
return lower_bound(all.begin(), all.end(), x) - all.begin() + 1;
};
Fenwick tr(all.size() + 5);
dp[0] = 1;
tr.add(find(w[0]), 1);
for(int i = 1; i < n; i++)
{
dp[i] = 1;
dp[i] = max((ll)dp[i], tr.query(find(w[i])) + 1);
tr.add(find(w[i]), dp[i]);
}
return *max_element(dp.begin(), dp.end()) >= m;
};
double l = -2e9, r = 2e9;
int times = 1000;
while(times--)
{
double mid = (l + r) / 2;
if(check(mid)) l = mid;
else r = mid;
}
cout << fixed << setprecision(15) << l << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
// int T; cin >> T; while(T--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-0.999999999999999
result:
ok found '-1.0000000', expected '-1.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3580kb
input:
2 2 1 1 5 3
output:
0.500000000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
2 2 222640995 547139825 489207317 725361095
output:
0.668581344645630
result:
ok found '0.6685813', expected '0.6685813', error '0.0000000'
Test #4:
score: 0
Accepted
time: 135ms
memory: 3776kb
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.793210462286661
result:
ok found '3.7932105', expected '3.7932105', error '0.0000000'
Test #5:
score: 0
Accepted
time: 143ms
memory: 3720kb
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...
output:
-1.860577876041861
result:
ok found '-1.8605779', expected '-1.8605779', error '0.0000000'
Test #6:
score: 0
Accepted
time: 692ms
memory: 3784kb
input:
5000 10 34774 620025564 366562 278306777 446710 509672662 650220 70882120 824803 317731338 881144 257861254 1063458 61483347 1071840 639872836 1263842 30790337 1591940 346781076 1964777 814735151 2067497 63962255 2220071 379252135 2539054 428050443 2937092 423099578 3088992 959927412 3229098 9591796...
output:
134.621472807091010
result:
ok found '134.6214728', expected '134.6214728', error '0.0000000'
Test #7:
score: 0
Accepted
time: 827ms
memory: 3804kb
input:
5000 20 199760 355854017 326334 308841311 562097 142603502 737215 739382649 740379 538515503 775788 515038260 817583 280515397 919169 892864353 972326 662840403 1344912 46143677 1550928 380148689 1589971 740794446 1638208 835030507 1707737 1806402 1736374 716485086 1738772 965202367 1855327 28929729...
output:
19.107398871059559
result:
ok found '19.1073989', expected '19.1073989', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
100 80 3642237 433728851 3835922 596838254 4822541 903206579 11786229 71614574 28051109 568783761 37988181 991770771 56927147 913182266 80808317 468372188 96532943 867642142 97069884 869788913 104938691 736691068 115294599 927608069 130086679 135340679 143622561 267761236 147838354 653078316 1483162...
output:
-45.917501529516663
result:
ok found '-45.9175015', expected '-45.9175015', error '0.0000000'
Test #9:
score: 0
Accepted
time: 12ms
memory: 3616kb
input:
300 300 186421 261109479 5746147 454165382 9237830 637520496 9851923 811263876 11414218 355514230 13089969 488595547 14673543 646754325 16206307 26512314 20111827 236176303 29494991 773939650 31542488 394434870 33151870 729247973 35483496 458610267 39685298 553345644 41333867 843739706 41339284 5952...
output:
-45869.322134004818508
result:
ok found '-45869.3221340', expected '-45869.3221340', error '0.0000000'
Test #10:
score: 0
Accepted
time: 94ms
memory: 3764kb
input:
1000 2 747727 310492171 1468650 713980779 3789328 757125223 5320562 240087911 5661018 585322880 5727658 166258339 9628311 1509468 9663570 644887821 9705398 201079132 11009052 79093580 11528729 273302786 14435306 891929759 16986960 794877487 17773102 990984060 19350978 246181882 19465885 427225500 23...
output:
145656.485252704180311
result:
ok found '145656.4852527', expected '145656.4852501', error '0.0000000'
Test #11:
score: 0
Accepted
time: 1398ms
memory: 3904kb
input:
10000 5000 11343 928311929 52379 840203434 261042 695151644 263788 172667944 364610 152184226 379806 619677738 515566 816745302 517646 466302942 540027 475750734 543982 124168292 640523 238869630 691715 468722215 705165 919447299 779673 129298873 1006841 948863833 1308410 643990798 1342527 5696458 1...
output:
-1045.873718454679874
result:
ok found '-1045.8737185', expected '-1045.8737185', error '0.0000000'
Test #12:
score: 0
Accepted
time: 1979ms
memory: 3928kb
input:
10000 500 83515 736933811 214681 18821934 337773 255421593 373401 682078732 542837 930642686 743115 251178260 798454 390884216 1209834 124196728 1262528 560215146 1351188 9091629 1563890 525243183 1574212 997260354 1580426 699829078 1750092 395252098 1869757 67867660 1875112 226384476 2047018 328213...
output:
-5.629902788399680
result:
ok found '-5.6299028', expected '-5.6299028', error '0.0000000'
Test #13:
score: -100
Time Limit Exceeded
input:
10000 300 1639 469147828 114667 8224138 144408 364515807 212973 961202084 398743 285809740 496841 927819708 534650 867558923 686967 588702382 696690 666164443 726922 781870146 872473 615520296 898161 178383389 985406 97264277 996652 703675454 1254375 530922354 1573412 745036174 1637763 177874295 167...