# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
577083 |
2022-06-14T03:24:44 Z |
vqpahmad |
Exam (eJOI20_exam) |
C++14 |
|
1000 ms |
168400 KB |
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define all(a) a.begin(),a.end()
#define mod (ll)(10000007)
using namespace std;
const int N = 1e6 + 15;
int mx ;
int n;
vector<int> b;
vector<int> a;
void solve(int pos,vector<int> v){
vector<int> temp = v;
if (pos==n){
int cnt =0;
for (int i=0;i<n;i++){
if (v[i]==b[i])cnt++;
}
cout << endl;
mx = max(mx,cnt);
return ;
}
bool can = 1;
int cur = pos;
while (v[cur]!=b[pos]){
if (v[cur]>b[pos]) {
can = 0;
break;
}
cur--;
if (cur==-1) {
can = 0;
break;
}
}
if (can){
for (int i=cur;i<=pos;i++){
v[i] = b[pos];
}
solve(pos+1,v);
v = temp;
}
cur = pos;
can = 1;
while (v[cur]!=b[pos]){
if (v[cur]>b[pos]) {
can = 0;
break;
}
cur++;
if (cur==n) {
can = 0;
break;
}
}
if (can){
for (int i=pos;i<=cur;i++){
v[i] = b[pos];
}
solve(cur+1,v);
}
solve(pos+1,temp);
return;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
a.resize(n);
b.resize(n);
for (int i=0;i<n;i++){
cin >> a[i];
}
for (int i=0;i<n;i++){
cin >> b[i];
}
solve(0,a);
cout << mx ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
8660 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1102 ms |
168400 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |