General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
101410908 Practice:
cornhub
920C - 69 GNU C++17 Accepted 77 ms 724 KB 2020-12-16 12:46:07 2020-12-16 12:46:07
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
     
    ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0); 	

ll int n,a; cin>>n;
string s,p; ll int maxx = 0;

for(int i=1;i<=n;i++)
{
cin>>a;	
maxx = max(a,maxx);
if(maxx==i) s.push_back('0'); else s.push_back('1');  // creating an optimal solution
}
s.pop_back(); // removing last element
cin>>p; bool flag = 1;
ll int j = 0;
for(auto x :p)  // checking if p is subset of s
{
if(s[j]=='1'&&x=='0')	
flag = 0;
j++;
}
if(flag) cout<<"YES";
else cout<<"NO";
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details