Submission #833587

# Submission time Handle Problem Language Result Execution time Memory
833587 2023-08-22T07:00:39 Z vjudge1 Exam (eJOI20_exam) C++17
14 / 100
661 ms 524288 KB
#include<bits/stdc++.h>
using namespace std;
 int n;
vector<int> h(100002), t(100002);
map<pair<int, vector<int>>, int> m;
int dp(int i, vector<int> v){
    if(i == n) return 0;
    if(m.count({i, v})>0) return m[{i, v}];

    int best=dp(i+1, v);
    vector<int> temp=v;
    for(int j=i; j<n; j++){
        if(v[j] > t[i]) break;
        if(v[j] == t[i]){
            while(j>i){
                v[j]=t[i];
                j--;
            }
            best=max(best, dp(i+1, v)+1);
            break;
        }
    }
    v=temp;
    for(int j=i; j>=0; j--){
        if(v[j] > t[i]) break;
        if(v[j] == t[i]){
            while(j<i){
                v[j]=t[i];
                j++;
            }
            best=max(best, dp(i+1, v)+1);
            break;
        }
    }
    m[{i, temp}]=best;
    return best;
}
int main(){
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>h[i];
    }
    for(int j=0; j<n; j++){
        cin>>t[j];
    }

    cout<<dp(0, h);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 3 ms 3788 KB Output is correct
3 Correct 3 ms 5324 KB Output is correct
4 Correct 5 ms 6092 KB Output is correct
5 Correct 14 ms 18252 KB Output is correct
6 Correct 5 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 26896 KB Output is correct
2 Runtime error 216 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 185 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 3 ms 3788 KB Output is correct
3 Correct 3 ms 5324 KB Output is correct
4 Correct 5 ms 6092 KB Output is correct
5 Correct 14 ms 18252 KB Output is correct
6 Correct 5 ms 8140 KB Output is correct
7 Correct 4 ms 6476 KB Output is correct
8 Runtime error 661 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2636 KB Output is correct
2 Correct 3 ms 3788 KB Output is correct
3 Correct 3 ms 5324 KB Output is correct
4 Correct 5 ms 6092 KB Output is correct
5 Correct 14 ms 18252 KB Output is correct
6 Correct 5 ms 8140 KB Output is correct
7 Correct 15 ms 26896 KB Output is correct
8 Runtime error 216 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -