#46676: 注意,這樣的寫法是NA(60%)


ck1090932@gl.ck.tp.edu.tw (陳邦仁)

學校 : 臺北市立建國高級中學
編號 : 131859
來源 : [140.112.24.194]
最後登入時間 :
2025-10-07 15:41:17

 
#include <iostream>
#include<set>
using namespace std;
set<int>s;
int n,q,h,d;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
cout.tie(0);
cin>>n>>q;int a[n];
cin>>h;a[0]=h;
for (int i=1;i<n;i++){
    cin>>h;a[i]=h;
    for (int j=0;j<i;j++){
        s.insert(abs(a[j]-h));
    }
}
for (int k=0;k<q;k++){
    cin>>d;
    if (s.count(d)==1){cout<<"YES\n";}
    else{cout<<"NO\n";}
}
return 0;
}

這樣子的寫法會 

SIGABRT 錯誤