QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#73666 | #2616. Attack Order | xlwang# | WA | 2ms | 3500kb | C++14 | 2.1kb | 2023-01-27 15:21:10 | 2023-01-27 15:21:14 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define randfind(l,r) (rand()%((r)-(l)+1)+(l))
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
using namespace std;
inline int read(){
int x=0;
bool f=0;
char c=getchar();
while(!isdigit(c)) f|=(c=='-'),c=getchar();
while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
return f?-x:x;
}
inline void write(int x){
if(x<0){putchar('-');x=-x;}
if(x>9)write(x/10);
putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
//inline void init(){
// int t=read();
// while(t--) work();
//}
const int Maxn=1e2+10;
int a[Maxn],b[Maxn];
int n;
int vis[Maxn];
struct node{
int val;
int id;
}e[Maxn];
int sum[Maxn];
inline bool cmp(node a,node b){return a.val<b.val;}
inline bool check(int x){
memset(vis,0,sizeof(vis));memset(sum,0,sizeof(sum));
vis[n]=1;
int l=1;
fr(i,1,n){
if(i==x){sum[i]=a[i]+b[n];continue;}
while(vis[e[l].id]) ++l;
int flag=0;
fr(j,l,n){
// writepl(i),writepl(j),writepl(e[j].id);
// puts("");
if(vis[e[j].id]) continue;
if(e[j].id==i) continue;
// puts("**");
if(e[j].val+a[i]>=sum[i-1]){
flag=1;vis[e[j].id]=1;
break;
}
}
if(!flag) return false;
}
return true;
}
inline void work(){
n=read();
fr(i,1,n) a[i]=read(),b[i]=read();
fr(i,1,n) e[i].id=i,e[i].val=b[i];
sort(e+1,e+n+1,cmp);
// fr(i,1,n) writepl(e[i].val),writeln(e[i].id);
fr(i,1,n-1) if(check(i)){
puts("Yes");
return;
}
puts("No");
}
inline void init(){
int t=read();
while(t--) work();
}
signed main(){
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
init();
// printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3412kb
input:
3 2 15 25 10 5 3 7 0 7 3 10 0 3 10 10 20 20 30 30
output:
Yes Yes No
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3500kb
input:
1000 4 0 1 0 2 2 2 0 0 4 2 2 1 1 1 1 0 0 4 2 1 1 2 1 0 2 1 3 2 1 1 0 1 1 4 2 0 2 2 1 2 1 2 3 1 0 3 0 0 3 4 1 1 1 0 1 2 1 2 2 1 2 3 1 4 1 2 1 0 2 0 0 2 2 3 3 0 2 4 2 0 1 0 2 1 0 1 3 1 1 1 0 0 3 4 1 1 2 1 0 2 1 1 4 1 2 2 2 1 0 2 1 4 0 0 1 0 0 1 0 1 3 0 1 2 3 0 0 3 3 1 3 2 1 1 4 1 0 0 0 1 1 2 1 4 2 1 1...
output:
Yes Yes Yes Yes Yes No Yes Yes Yes No Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No Yes No Yes...
result:
wrong answer expected NO, found YES [1st token]