Submission #757923

# Submission time Handle Problem Language Result Execution time Memory
757923 2023-06-14T01:55:45 Z Dexva Fruits (NOI22_fruits) C++14
6 / 100
88 ms 9460 KB
#include <bits/stdc++.h>
using namespace std;

#define lln long long

void solve() {
    int n; cin >> n;
    int ans[n], ref[n], cost[n];
    for (int i=0;i<n;i++) ans[i] = 0;
    for (int i=0;i<n;i++) cin >> ref[i];
    for (int i=0;i<n;i++) cin >> cost[i];
    
    vector<int> cur; //what we will permutate over
    for (int i=0;i<n;i++) {
        cur.push_back(i);
    }

    if (n<=8) { // do brute force solution
        do {
            bool ok = true;
            for (int i=0;i<n;i++) {
                if (ref[i]!=-1 && ref[i]-1!=cur[i]) {
                    ok = false;
                    break;
                }
            }
            if (!ok) continue;
            // else {
            //     for (int i=0;i<n;i++) cout << cur[i] << " ";
            //     cout << '\n';
            // }

            int cursum = 0, maxtaste = -1;
            for (int k=0;k<n;k++) {
                if (cur[k]>maxtaste) {
                    cursum += cost[cur[k]];
                    maxtaste = cur[k];
                }
                // if (cursum > ans[k]) {
                //     cout << k << " | | " << "current perm: ";
                //     for (int i=0;i<n;i++) cout << cur[i] << " ";
                //     cout << '\n';
                // }
                ans[k] = max(ans[k], cursum);
            }
        } while (next_permutation(cur.begin(),cur.end()));
    } 

    else {
        int cursum = 0;
        for (int k=0;k<n;k++) {
            cursum += cost[k];
            ans[k] = cursum;
        }
    } //do dumb greedy solution

    for (int k=0;k<n;k++) {
        cout << ans[k] << " ";
    } cout << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    while (t--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 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 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 9460 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 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -