QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#759083 | #3573. Joint Venture | gyydp123_LIM | 100 ✓ | 531ms | 7892kb | C++20 | 1006b | 2024-11-17 21:31:10 | 2024-11-17 21:31:11 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);++i)
#define ForDown(i,j,k) for(int i=(j);i>=(k);--i)
#define Debug(fmt, args...) fprintf(stderr,"(func %s, line #%d): " fmt,__func__,__LINE__,##args),fflush(stderr)
#define debug(fmt, args...) fprintf(stderr,fmt,##args),fflush(stderr)
#define within :
#define LJY main
using namespace std;
typedef long long ll;
const int N=1e6+5;
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
inline int read(){
char ch=getchar();int x=0,f=1;
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')
x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return x*f;
}
int x,n,a[N];
void ljy(){
x=x*10000000;n=read();
For(i,1,n) a[i]=read();
sort(a+1,a+1+n);
For(i,1,n){
if(a[i]*2>x) break;
int j=upper_bound(a+i+1,a+1+n,x-a[i])-a-1;
if(j>i&&j<=n&&a[j]+a[i]==x){printf("yes %d %d\n",a[i],a[j]);return;}
}puts("danger");
}
signed LJY(){while(scanf("%d",&x)==1) ljy();}
詳細信息
Pretests
Final Tests
Test #1:
score: 100
Accepted
time: 531ms
memory: 7892kb
input:
1 4 9999998 1 2 9999999 1 0 1 1 5 1 1 10000000 1 1 5000000 1 2 9999997 3 1 2 9999998 3 1 3 2 9999997 5000000 1 3 4 9999996 5000000 1 3 5000000 5000000 5000000 1 3 5000000 5000000 2345 1 3 5000000 3455 5000000 1 3 6000000 5000000 5000000 1 4 2000000 3000000 5000000 6000000 1 4 2000000 4000000 5000000...
output:
yes 1 9999999 danger danger danger danger yes 3 9999997 danger danger yes 4 9999996 yes 5000000 5000000 yes 5000000 5000000 yes 5000000 5000000 yes 5000000 5000000 danger yes 4000000 6000000 yes 4000000 6000000 yes 5000000 5000000 yes 4999999 5000001 danger danger danger yes 5000000 5000000 yes 1103...
result:
ok 26 lines