Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- const int MX = (1<<18);
- int T , n , m;
- int cnt[1<<18];
- int main(){
- cin>>T;
- while(T--){
- cin>>n;
- for(int j = 1 ; j <= n ; j++) cnt[j] = 0;
- cin>>m;
- bool notok = 0;
- int x;
- for(int j = 1 ; j <= m ; j++){
- cin>>x;
- bool ch = 0;
- for(int i = 1 ; i <= n ; i++)
- if(i != x)
- ch |= (cnt[x] > cnt[i]);
- notok |= ch;
- ++cnt[x];
- }
- if(notok) puts("NO");
- else puts("YES");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement