답안 #576500

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576500 2022-06-13T06:48:45 Z MuntherCarrot Exam (eJOI20_exam) C++14
12 / 100
25 ms 3520 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define all(x) x.begin(),x.end()
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int students;
    cin >> students;
    vector<int> A(students),B(students);
    for(int i=0;i<students;i++) cin >> A[i];
    for(int i=0;i<students;i++) cin >> B[i];
    vector<int> ans(students,0);
    int x=0;
    for(int i=0;i<students;i++){
        if(A[i] >= B[i]) ans[i]=A[i];
    }
    bool q=0;
    for(int i=0;i<students;i++){
        if(ans[i] == B[i])q=1;
        if(ans[i] > B[i])q=0;
        if(q) ans[i]=B[i];
    }
    q=0;
    for(int i=students-1;i>=0;i--){
        if(ans[i] == B[i])q=1;
        if(ans[i] > B[i])q=0;
        if(q) ans[i]=B[i];
    }
    for(int i=1;i<students;i++){
        if(ans[i] == 0) ans[i]=ans[i-1];
    }
    for(int i=students-2;i>=0;i--){
        if(ans[i] == 0) ans[i]=ans[i+1];
    }
    int counter=0;
    for(int i=0;i<students;i++){
            //cout << ans[i] << ' ';
        if(ans[i]==B[i]) counter++;
    }
    cout << counter;
    return 0;
}

Compilation message

exam.cpp: In function 'int main()':
exam.cpp:15:9: warning: unused variable 'x' [-Wunused-variable]
   15 |     int x=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 868 KB Output is correct
3 Correct 16 ms 2408 KB Output is correct
4 Correct 16 ms 1876 KB Output is correct
5 Correct 25 ms 3520 KB Output is correct
6 Correct 12 ms 1880 KB Output is correct
7 Correct 17 ms 2056 KB Output is correct
8 Correct 25 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -