Submission #66339

# Submission time Handle Problem Language Result Execution time Memory
66339 2018-08-10T09:08:13 Z someone_aa Gondola (IOI14_gondola) C++17
55 / 100
24 ms 4560 KB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;
const int maxn = 250100;
bool exist[maxn];
int fin_val[maxn];

int valid(int n, int arr[]) {
    bool check = true;

    for(int i=1;i<n;i++) {
        if(arr[i] > n) continue;
        else if(arr[i] == 1) {
            if(arr[i-1] < n)
                check = false;
        }
        else {
            if(arr[i-1] <= n && arr[i-1] != arr[i] - 1) check = false;
        }
    }

    sort(arr, arr+n);
    for(int i=1;i<n;i++) {
        if(arr[i] == arr[i-1]) check = false;
    }
    if(check) return 1;
    else return 0;
}

//----------------------

int replacement(int n, int arr[], int replacementSeq[]) {
    int maxm = 0;
    int found_i = 0, st_val = 1;
    for(int i=0;i<n;i++) {
        exist[arr[i]] = true;
        if(arr[i] <= n) {
            found_i = i;
            st_val = arr[i];
        }
        maxm = max(maxm, arr[i]);
    }
    exist[n] = true;
    int l = maxm - n;


    for(int i=found_i;i<n;i++) {
        fin_val[i] = st_val;
        st_val++;
        if(st_val == n + 1) st_val = 1;
    }

    for(int i=0;i<found_i;i++) {
        fin_val[i] = st_val;
        st_val++;
        if(st_val == n + 1) st_val = 1;
    }

    for(int i=0;i<n;i++) {
        while(!exist[arr[i]-1] && arr[i] > n) {
            replacementSeq[arr[i]-n-1] = arr[i] - 1;
            arr[i]--;
        }
        if(arr[i] > n) replacementSeq[arr[i]-n-1] = fin_val[i];
    }

    return l;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

/*int main() {
    int arr[] = {3, 1, 4};
    int arr2[1];
    cout<<replacement(3, arr, arr2);
}*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 544 KB Output is correct
2 Correct 2 ms 544 KB Output is correct
3 Correct 3 ms 544 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 656 KB Output is correct
6 Correct 9 ms 784 KB Output is correct
7 Correct 21 ms 820 KB Output is correct
8 Correct 14 ms 848 KB Output is correct
9 Correct 7 ms 848 KB Output is correct
10 Correct 21 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 848 KB Output is correct
2 Correct 2 ms 848 KB Output is correct
3 Correct 2 ms 848 KB Output is correct
4 Correct 2 ms 848 KB Output is correct
5 Correct 2 ms 848 KB Output is correct
6 Correct 10 ms 848 KB Output is correct
7 Correct 24 ms 876 KB Output is correct
8 Correct 13 ms 876 KB Output is correct
9 Correct 7 ms 876 KB Output is correct
10 Correct 22 ms 876 KB Output is correct
11 Correct 2 ms 876 KB Output is correct
12 Correct 2 ms 876 KB Output is correct
13 Correct 11 ms 876 KB Output is correct
14 Correct 2 ms 876 KB Output is correct
15 Correct 22 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 2 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 2 ms 896 KB Output is correct
3 Correct 2 ms 896 KB Output is correct
4 Correct 2 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 2 ms 896 KB Output is correct
7 Correct 2 ms 896 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 2 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 2 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 2 ms 896 KB Output is correct
7 Correct 3 ms 896 KB Output is correct
8 Correct 3 ms 896 KB Output is correct
9 Correct 3 ms 896 KB Output is correct
10 Correct 3 ms 896 KB Output is correct
11 Correct 15 ms 1992 KB Output is correct
12 Correct 15 ms 2700 KB Output is correct
13 Correct 15 ms 3088 KB Output is correct
14 Correct 13 ms 3168 KB Output is correct
15 Correct 23 ms 4560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4560 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4560 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4560 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 4560 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -