提交时间:2024-01-07 13:58:40

运行 ID: 229927

#include <bits/stdc++.h> using namespace std; int main() { int t,n,k,a[10005],u,v; bool b=1; cin >> t; for (int i=1;i<=t;i++) { cin >> n >> k; for (int j=1;j<=n;j++) { cin >> a[j]; } for (int j=1;j<=k;j++) { cin >> u >> v; a[u]+=1; a[v]-=1; } for (int j=1;j<n;j++) { if (a[j]>a[j+1]) { b=0; } } if (b==1) { cout << "Yes" << endl; }else { cout << "No" << endl; } } return 0; }