QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#241598 | #6401. Classic: N Real DNA Pots | ucup-team902# | WA | 1ms | 5964kb | C++14 | 1.5kb | 2023-11-06 13:03:06 | 2023-11-06 13:03:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define gc c=getchar()
#define r(x) read(x)
#define ll long long
#define db double
template<typename T>
inline void read(T &x){
x=0;T k=1;char gc;
while(!isdigit(c)){if(c=='-')k=-1;gc;}
while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}
const int N = 1e5 + 7;
const db INF = 1e18;
#define ls (rt << 1)
#define rs (ls | 1)
db tr[N << 2];
void ins(int rt, int l, int r, int x, db v){
if(l == r){
tr[rt] = v;
return ;
}
int mid = (l + r) >> 1;
if(x <= mid) ins(ls, l, mid, x, v);
else ins(rs, mid + 1, r, x, v);
tr[rt] = min(tr[ls], tr[rs]);
}
db query(int rt, int l, int r, int x, int y){
if(l == r){
return tr[rt];
}
int mid = (l + r) >> 1;
if(y <= mid) return query(ls, l, mid, x, y);
if(x > mid) return query(rs, mid + 1, r, x, y);
return min(query(ls, l, mid, x, y), query(rs, mid + 1, r, x, y));
}
int x[N];
int y[N];
int main(){
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int n, k; r(n), r(k);
for(int i = 1; i <= n; ++i){
r(x[i]), r(y[i]);
}
for(int i = 1; i < n; ++i){
db t = (db)(y[i + 1] - y[i]) / (x[i + 1] - x[i]);
ins(1, 1, n - 1, i, t);
}
db ans = -INF;
for(int i = 1; i + k - 2 < n; ++i){
ans = max(ans, query(1, 1, n - 1, i, i + k - 2));
}
printf("%.10lf\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
4 3 1 2 2 4 3 3 4 1
output:
-1.0000000000
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5964kb
input:
2 2 1 1 5 3
output:
0.5000000000
result:
ok found '0.5000000', expected '0.5000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 5936kb
input:
2 2 222640995 547139825 489207317 725361095
output:
0.6685813446
result:
ok found '0.6685813', expected '0.6685813', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3976kb
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:
-350.8084323949
result:
wrong answer 1st numbers differ - expected: '3.7932105', found: '-350.8084324', error = '93.4832502'