Codeforces Round #600 (Div. 2) A. Single Push

Posted qingyuyyyyy

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #600 (Div. 2) A. Single Push相关的知识,希望对你有一定的参考价值。

  

#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int T,n;
int a[100001],b[100001];
int main() {
    scanf("%d",&T);
    while(T--) {
        scanf("%d",&n);
        for(int i=1; i<=n; i++)scanf("%d",&a[i]);
        for(int i=1; i<=n; i++)scanf("%d",&b[i]);
        int fl=0,t,fl2=0,j;
        for(int i=1; i<=n; i++) {
            if(a[i]^b[i]) {
                t=b[i]-a[i];
                if(t<=0) {
                    fl=1;
                    break;
                }
                for(j=i+1; j<=n; j++) {
                    if(b[j]==a[j])break;
                    if(b[j]-a[j]!=t) {
                        fl2=1;
                        break;
                    }
                }
                if(!fl2) {
                    for(j; j<=n; j++)if(a[j]!=b[j]) {
                            fl=1;
                            break;
                        }
                } else fl=1;
                break;
            }
        }
        printf(fl?"NO
":"YES
");

    }
    return 0;
}

 

以上是关于Codeforces Round #600 (Div. 2) A. Single Push的主要内容,如果未能解决你的问题,请参考以下文章

第五天打卡 Codeforces Round #600 (Div. 2)

cf比赛记录Codeforces Round #600 (Div. 2)

Codeforces Round #600 (Div. 2)

Codeforces Round #600 (Div. 2) E. Antenna Coverage

Codeforces Round #600 (Div. 2) A. Single Push

Codeforces Round #600 (Div. 2) B. Silly Mistake