| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1046254 | Nickpapadak | Exam (eJOI20_exam) | C++14 | 3 ms | 856 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100010
#define INF 1000000010
int N, B[MAXN];
int A[MAXN];
pair<int,int> Range[MAXN];
int solveEQ(){
    int ans = 0;
    int i = 1, j =1;
    bool foundB = false;
    for(;j<=N;++j){
        if(A[j] > B[1]) {
            ans += (j-i) * foundB;           
            i= j+1;
            foundB = false;
        }
        else if(A[j] == B[1]) foundB= true;
    }
    return ans;
}
void setRange(){
    A[0] = INF;
    A[N+1] = INF;
    for(int i =1;i<=N;++i){
        int j =i,k =i;
        while(A[j-1] <= A[i] || A[k+1] <=A[i]){
            if(A[j-1] <= A[i]) --j;
            if(A[k+1] <= A[i]) ++k;
        }
        Range[i] = {j,k};
    }
}
int solveSORT(){
    int ans =0;
    for(int i = 1;i<=N;++i){
        for(int j = Range[i].first; j<=Range[i].second; ++j){
            if(B[j] == A[i]) ans++;
        }
    }
    
    return ans;
}
int main(){
    scanf("%d",&N);
    for(int i=1;i<=N;++i){
        scanf("%d",&A[i]);
    }
    bool AllB = true;
    for(int i =1;i<=N;++i){
        scanf("%d",&B[i]);
        if(B[i] != B[i-1] && i > 1) AllB = false;
    }
    if(AllB)
        printf("%d\n", solveEQ());
    else if(is_sorted(A+1, A+N+1)){
        setRange();
        printf("%d\n", solveSORT());
    }
    
    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... | ||||
