Submission #314770

# Submission time Handle Problem Language Result Execution time Memory
314770 2020-10-21T06:57:45 Z kubo Detecting Molecules (IOI16_molecules) C
0 / 100
1 ms 256 KB
#include <stdio.h>
#include <stdlib.h>


int cmpfunc (const void * a, const void * b)
{
    return ( *(int*)a - *(int*)b );
}


int find_subset (int l, int u, int* w, int n, int* result)
{
    qsort(w, n, sizeof(int), cmpfunc);
    int i = 0, j = 0;
    long v = 0;
    do {
        if (v < l && j<n) {
            v += w[j++];
        } else if (v > u && i<n) {
            v -= w[i++];
        } else {
            break;
        }
        /* printf("%d %d %ld\n", i, j, v); */
    } while (1);

    if (v>=l && v<=u) {
        for (int k=i; k<j; ++k)
            result[k-i] = w[k];
        return j-i;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Integer 50 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -