Submission #832475

# Submission time Handle Problem Language Result Execution time Memory
832475 2023-08-21T10:45:13 Z Liudas Fruits (NOI22_fruits) C++17
0 / 100
343 ms 29100 KB
#include <vector>
#include <iostream>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> arr(N), brr(N);
    set<int> used;
    for(int i = 0; i < N; i ++){
        cin >> arr[i];
        used.insert(arr[i]);
    }
    for(int i = 0; i < N; i ++){
        cin >> brr[i];
    }
    int maxi = -1;
    set<int> left;
    for(int i = 1; i <= N; i ++){
        if(used.find(i) == used.end())
        left.insert(i);
    }
    vector<int> C(N);
    for(int i = 0; i < N; i ++){
        maxi = max(arr[i], maxi);
        if(arr[i] != -1)continue;
        if(left.lower_bound(maxi+1)!=left.end()){
            arr[i] = *left.lower_bound(maxi+1);
            left.erase(left.lower_bound(maxi+1));
        }
        else{
            arr[i] = *left.begin();
            left.erase(left.begin());
        }
        maxi = max(maxi, arr[i]);
    }
    int c = 0;
    maxi = -1;
    for(int i = 0; i < N; i ++){
        if(arr[i] > maxi){
            c += brr[arr[i]-1];
            maxi = arr[i];
        }
        C[i] = c;
    }
    for(int i : arr){
        cout << i << " ";
    }
    cout << endl;
    for(int i : C){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 343 ms 29100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -