Submission #765644

#TimeUsernameProblemLanguageResultExecution timeMemory
765644boyliguanhanScales (IOI15_scales)C++17
21.74 / 100
1 ms212 KiB
#include "scales.h"
int lightest(int sz, int x[], int f) {
    if(sz==5) {
        return getLightest(x[0],x[1],getLightest(x[2],x[3],x[4]));
    }
    if(sz==3) {
        return getLightest(x[0],x[1],x[2]);
    }
    if(sz==1) {
        return x[0];
    }
    if(sz==2) {
        return getMedian(x[0],x[1],f);
    }
    if(sz==4) {
        return getLightest(x[0],x[1],getMedian(x[2],x[3],f));
    }
    int a = getLightest(1,2,3);
    int b = getLightest(4,5,6);
    if(a==3) {
        return getLightest(a,b,2);
    } else {
        return getLightest(a,b,3);
    }
}
void remove(int arr[], int val) {
    getLightest(1,2,3);
    int x = 0;
    while(arr[x]!=val) x++;
    while(x<5) {
        arr[x] = arr[x+1];
        x++;
    }
}
void init(int T) {}
void orderCoins() {
    int pos[6] = {1,2,3,4,5,6}, w[6] = {0,0,0,0,0,0};
    int f = w[0] = lightest(6,pos,0);
    remove(pos,f);
    for(int i = 1; i < 6; i++) {
        remove(pos, w[i] = lightest(6-i,pos,f));
    }
    answer(w);
}

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:35:15: warning: unused parameter 'T' [-Wunused-parameter]
   35 | void init(int T) {}
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...