Submission #2117751


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main()
{
    int K, *data, i, j, k, l, *prev_list, *next_list, num_of_prev_list = 1, num_of_next_list, count, min_N = INT_MAX, max_N = INT_MIN;
    
    scanf("%d", &K);
    data = (int *)malloc(sizeof(int) * K);
    for (i = 0; i < K; i++){
        scanf("%d", &data[i]);
    }
    
    prev_list = (int *)malloc(sizeof(int) * num_of_prev_list);
    prev_list[0] = 2;
    
    for (i = K - 1; i >= 0; i--, l = 0) {
        num_of_next_list = 2 * data[i];
        next_list = (int *)malloc(sizeof(int) * num_of_next_list);
        
        j = 0;
        while (prev_list[j] % data[i] != 0 && j <= num_of_prev_list - 1)
            j++;
        if (j == num_of_prev_list) {
            printf("-1\n");
            free(data);
            free(prev_list);
            free(next_list);
            return 0;
        }
        for (k = 0; k < data[i]; k++, l++)
            next_list[l] = prev_list[j] + k;
        
        j = num_of_prev_list - 1;
        while (prev_list[j] % data[i] != 0 && j >= 0)
            j--;
        if (j == -1) {
            printf("-1\n");
            free(data);
            free(prev_list);
            free(next_list);
            return 0;
        }
        for (k = 0; k < data[i]; k++, l++)
            next_list[l] = prev_list[j] + k;
        
        prev_list = (int *)malloc(sizeof(int) * num_of_next_list);
        num_of_prev_list = num_of_next_list;
        for (j = 0; j < num_of_next_list; j++){
            prev_list[j] = next_list[j];
        }
        
        if (num_of_next_list == 0) {
            printf("-1\n");
            free(data);
            free(prev_list);
            free(next_list);
            return 0;
        }
    }
    
    for (i = 0; i < num_of_next_list; i++) {
        if (next_list[i] <= min_N)
            min_N = next_list[i];
        if (next_list[i] >= max_N)
            max_N = next_list[i];
    }
    
    printf("%d %d\n", min_N, max_N);
    
    free(data);
    free(prev_list);
    free(next_list);
    return 0;
}

Submission Info

Submission Time
Task B - Ice Rink Game
User ytsuyo9746
Language C (GCC 5.4.1)
Score 0
Code Size 2140 Byte
Status RE
Exec Time 2295 ms
Memory 6784 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:9:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &K);
     ^
./Main.c:12:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &data[i]);
         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 500
Status
AC × 3
AC × 19
WA × 8
TLE × 2
RE × 4
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_26.txt, subtask_1_27.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 128 KB
sample_02.txt AC 1 ms 128 KB
sample_03.txt AC 1 ms 128 KB
subtask_1_01.txt AC 1 ms 128 KB
subtask_1_02.txt AC 1 ms 128 KB
subtask_1_03.txt AC 1 ms 128 KB
subtask_1_04.txt AC 1 ms 128 KB
subtask_1_05.txt AC 1 ms 128 KB
subtask_1_06.txt AC 17 ms 6784 KB
subtask_1_07.txt AC 13 ms 512 KB
subtask_1_08.txt WA 1 ms 128 KB
subtask_1_09.txt WA 1 ms 128 KB
subtask_1_10.txt WA 1 ms 256 KB
subtask_1_11.txt WA 13 ms 512 KB
subtask_1_12.txt WA 13 ms 512 KB
subtask_1_13.txt TLE 2295 ms -1160832 KB
subtask_1_14.txt AC 13 ms 512 KB
subtask_1_15.txt AC 13 ms 640 KB
subtask_1_16.txt WA 2 ms 256 KB
subtask_1_17.txt WA 11 ms 512 KB
subtask_1_18.txt WA 11 ms 512 KB
subtask_1_19.txt AC 10 ms 512 KB
subtask_1_20.txt AC 11 ms 512 KB
subtask_1_21.txt AC 12 ms 512 KB
subtask_1_22.txt AC 12 ms 512 KB
subtask_1_23.txt TLE 2150 ms -1048320 KB
subtask_1_24.txt RE 1770 ms -1048320 KB
subtask_1_25.txt RE 1829 ms -1047936 KB
subtask_1_26.txt RE 2093 ms -1048320 KB
subtask_1_27.txt RE 1819 ms -1047936 KB