# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
411605 | aris12345678 | Exam (eJOI20_exam) | C++14 | 259 ms | 1048 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5+5;
int a[mxN], b[mxN];
bool sub2(int n) {
for(int i = 1; i < n; i++) {
if(b[i] != b[i-1])
return false;
}
return true;
}
int main() {
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n; i++)
scanf("%d", &b[i]);
if(sub2(n)) {
int i = 0, j = 0, mx = 0, ans = 0;
while(j < n) {
if(a[j] > b[0] && mx == b[0])
ans += (j-i), mx = 0;
while(a[j] > b[0])
j++, i = j;
mx = max(mx, a[j++]);
}
if(mx == b[0])
ans += (j-i);
printf("%d\n", ans);
} else {
int ans = 0;
for(int mask = 0; mask < 1 << n; mask++) {
int res = 0, prev_i = 0;
map<int, int> left, right;
for(int i = 0; i < n; i++) {
if(mask&(1 << i)) {
for(int j = prev_i+1; j < i; j++) {
if(a[j] < a[i])
left[b[j]]++;
}
for(int j = i+1; j < n; j++) {
if(mask&(1 << j)) break;
if(a[j] < a[i])
right[b[j]]++;
}
res += left[a[i]]+right[a[i]];
left.clear();
right.clear();
prev_i = i;
}
}
left.clear();
right.clear();
ans = max(ans, res);
}
for(int i = 0; i < n; i++) {
if(a[i] == b[i])
ans++;
}
printf("%d\n", ans);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |