QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#35311#2616. Attack OrderyzhangWA 2ms3664kbC++171.2kb2022-06-15 08:21:432022-06-15 08:21:44

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-06-15 08:21:44]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2022-06-15 08:21:43]
  • 提交

answer

//μ's forever
#include <bits/stdc++.h>
#define N 105
//#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int T,n;
int a[N],b[N];
int main()
{
    T=read();
    while(T--){
        n=read();
        for(int i=1;i<=n;++i) a[i]=read();
        for(int i=1;i<=n;++i) b[i]=read();
        if(n==1||n==2){
            puts("Yes");
            continue;
        }
        bool fl=1;
        int sm=0;
        for(int i=1;i<=n;++i) sm+=b[i];
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
                if(a[i]>a[j]){
                    if(a[j]+sm-b[j]>a[i])
                        fl=0;
                }
        puts(fl?"Yes":"No");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3664kb

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: 3484kb

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:

No
No
No
Yes
No
No
No
Yes
No
Yes
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
No
No
No
No
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No...

result:

wrong answer expected NO, found YES [4th token]