Submission #833584

# Submission time Handle Problem Language Result Execution time Memory
833584 2023-08-22T06:59:45 Z vjudge1 Exam (eJOI20_exam) C++17
12 / 100
59 ms 1460 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 10;
const int INF = INT_MAX;
const long long LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;


void solv(){
    int n;
    cin >> n;
    int h[n], t[n];
    for(int i = 0; i < n; i++)cin >> h[i];
    bool same = 1;
    for(int i = 0; i < n; i++){
        cin >> t[i];
        if(i != 0)if(t[i] != t[i-1])same = false;
    }

    if(same){
        int temp = t[0];
        int ans = 0;
        int nyala[n] = {};
        int now = 0;
        bool cashin = false;
        for(int i = 0; i < n; i++){
            if(h[i] < temp){
                now++;
            }
            if(h[i] == temp){
                now++;
                cashin = true;
            }
            if(h[i] > temp){
                if(cashin){
                    ans += now;
                    cashin = false;
                }
                now = 0;
            }
        }
        if(cashin){
            ans += now;
        }
        cout << ans << endl;
    }else{
        int before[n] = {};
        int ans = 0;
        for(int i = 0; i < n; i++){
            int after[n+5] = {};
            int l = i;
            int mx = -1;
            for(int j = i; j >= 0; j--){
                if(h[i] == t[j]){
                    after[j] = after[j+1] + 1;
                }else{
                    after[j] = after[j+1];
                }

                if(after[j] - before[j] >mx){
                    mx = after[j] - before[j];
                }
            }
            for(int j = i; j >= 0; j--){
                before[j] = after[j];
            }
            ans += mx;
        }
        cout << ans << endl;
    }
}

int main(){
    int tc = 1;
//    cin >> tc;
    while(tc--)solv();
    return 0;
}

Compilation message

exam.cpp: In function 'void solv()':
exam.cpp:26:13: warning: unused variable 'nyala' [-Wunused-variable]
   26 |         int nyala[n] = {};
      |             ^~~~~
exam.cpp:54:17: warning: unused variable 'l' [-Wunused-variable]
   54 |             int l = i;
      |                 ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 11 ms 468 KB Output is correct
3 Correct 34 ms 1228 KB Output is correct
4 Correct 21 ms 1460 KB Output is correct
5 Correct 59 ms 1356 KB Output is correct
6 Correct 22 ms 1364 KB Output is correct
7 Correct 25 ms 1356 KB Output is correct
8 Correct 55 ms 1356 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 32 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -