Submission #832458

# Submission time Handle Problem Language Result Execution time Memory
832458 2023-08-21T10:36:36 Z Liudas Fruits (NOI22_fruits) C++17
0 / 100
310 ms 28640 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());
        }
    }
    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 : C){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 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 300 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 300 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 295 ms 28640 KB Output is correct
2 Incorrect 310 ms 28364 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 300 KB Output isn't correct
3 Halted 0 ms 0 KB -