QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#35313#2616. Attack OrderyzhangWA 2ms3664kbC++171.5kb2022-06-15 08:26:352022-06-15 08:26:37

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:26:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3664kb
  • [2022-06-15 08:26:35]
  • 提交

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];
map<int,int> mp;
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;
                }
        mp.clear();
        for(int i=1;i<=n&&fl;++i){
            if(sm-b[i]>0){
                // cerr<<i<<endl;
                if(mp[a[i]]) fl=0;
                else mp[a[i]]=1;
            }
        }
        puts(fl?"Yes":"No");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
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
No
No

result:

wrong answer expected YES, found NO [2nd token]