QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#111760 | #6401. Classic: N Real DNA Pots | do_while_true# | WA | 2ms | 3672kb | C++14 | 2.2kb | 2023-06-08 16:08:59 | 2023-06-08 16:09:01 |
Judging History
answer
#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n';
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n';
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pil>vpil;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
r=0;bool w=0;char ch=getchar();
while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
int s=1;
while(y){
if(y&1)s=1ll*s*x%mod;
x=1ll*x*x%mod;
y>>=1;
}
return s;
}
const int N=100010;
int n,k;
pii a[N];
ld b[N];
int tot;
int check(ld mid){
tot=0;
for(int i=n;i>=1;i--){
ld x=a[i].se-a[i].fi*mid;
if(!tot || x>=b[tot])b[++tot]=x;
else{
int p=lower_bound(b+1,b+tot+1,x)-b;
b[p]=x;
}
}
return tot>=k;
}
signed main(){
#ifdef do_while_true
assert(freopen("data.in","r",stdin));
// assert(freopen("data.out","w",stdout));
#endif
read(n,k);
for(int i=1;i<=n;i++){
int x,y;read(x,y);
a[i]=mp(x,y);
}
ld l=-1000000010,r=1000000010,mid,as=1000000000;
for(int i=1;i<=200;i++){
mid=(l+r)/2;
if(check(mid))as=mid,r=mid;
else l=mid;
}
printf("%.10lf\n",as);
#ifdef do_while_true
cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
#endif
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3668kb
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: 2ms
memory: 3672kb
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: 2ms
memory: 3428kb
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: 2ms
memory: 3404kb
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.4053041779
result:
wrong answer 1st numbers differ - expected: '3.7932105', found: '-3.4053042', error = '1.8977367'