Submission #576588

# Submission time Handle Problem Language Result Execution time Memory
576588 2022-06-13T08:20:13 Z vqpahmad Exam (eJOI20_exam) C++14
12 / 100
22 ms 1108 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 mx = 1e6 + 15;




int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> ab(n);
    bool flag = 1;
    bool ans = 0;
    for (int i=0;i<n;i++){
        cin >> ab[i].first;
    }
    for (int i=0;i<n;i++){
        cin >> ab[i].second;
        if (i){
            if (ab[i-1].second!=ab[i].second) flag = 0;
        }
    }
    for (int i=0;i<n;i++){
        if (ab[i].first==ab[i].second) ans = 1;
    }
    if (flag&&ans) {
        int cnt =0;
        for (int i=0;i<n;i++){
            if (ab[i].first==ab[i].second){
                int p = i;
                while (ab[p].first<=ab[i].second){
                    cnt++;
                    p--;
                    if (p==-1) break;
                }
                p = i+1;
                if (p!=n){
                    while (ab[p].first<=ab[i].second){
                        cnt++;
                        p++;
                        if (p==n) break;
                    }
                }
                i = p-1;
            }
        }
        cout << cnt ;
    }
    else cout << 0 << endl;

    
}
# 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 Correct 0 ms 212 KB Output is correct
2 Correct 4 ms 468 KB Output is correct
3 Correct 17 ms 980 KB Output is correct
4 Correct 13 ms 1108 KB Output is correct
5 Correct 22 ms 1108 KB Output is correct
6 Correct 9 ms 1108 KB Output is correct
7 Correct 12 ms 1108 KB Output is correct
8 Correct 19 ms 1108 KB Output is correct
# 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 Incorrect 2 ms 340 KB Output isn't correct
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 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -