Submission #16553784


Source Code Expand

Copy
#include <stdio.h>

void    swap(int company[4][50000], int i, int j)
{
        int     temp;
        int     k;

        for (k = 0; k < 4; k++)
        {
                temp = company[k][i];
                company[k][i] = company[k][j];
                company[k][j] = temp;
        }
}


void    quick_sort_company(int company[4][50000], int left, int right)
{
        int     pivot_index;
        int     pivot;
        int     i;
        int     j;

        if (right - left == 1)
                return ;
        pivot_index = (left + right) / 2;
        pivot = company[3][pivot_index];
        swap(company, pivot_index, right - 1);
        i = 0;
        for (j = 0; j < right - 1; j++)
        {
                if (company[3][j] > pivot)
                {
                        swap(company, i, j);
                        i++;
                }
        }
        swap(company, i, right - 1);
        quick_sort_company(company, 0, i);
        quick_sort_company(company, i + 1, right);
}

int             check_condition(int human[3][50000], int company[4][50000], int i, int j)
{
        int k;

        for (k = 0; k < 3; k++)
        {
                if (company[k][j] > human[k][i])
                        return (0);
        }
        return (1);
}

int             main(void)
{
        int     n;
        int     m;
        int     company[4][50000];
        int     human[3][50000];
        int     answer[50000] = {0};
        int     i;
        int     j;

        scanf("%d%d", &n, &m);
        for (i = 0; i < n; i++)
        {
                scanf("%d%d%d%d", &company[0][i], &company[1][i], &company[2][i], &company[3][i]);
        }
        for (i = 0; i < m; i++)
        {
                scanf("%d%d%d", &human[0][i], &human[1][i], &human[2][i]);
        }
        quick_sort_company(company, 0, n);
        for (i = 0; i < m; i++)
        {
                for (j = 0; j < n; j++)
                {
                        if (check_condition(human, company, i, j))
                        {
                                answer[i] = company[3][j];
                                break ;
                        }
                }
        }
        for (i = 0; i < m; i++)
        {
                printf("%d\n", answer[i]);
        }
        return (0);
}

Submission Info

Submission Time
Task C - Optimal Recommendations
User atsuk
Language C (GCC 9.2.1)
Score 0
Code Size 2388 Byte
Status RE
Exec Time 2205 ms
Memory 257516 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:65:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   65 |         scanf("%d%d", &n, &m);
      |         ^~~~~~~~~~~~~~~~~~~~~
./Main.c:68:17: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   68 |                 scanf("%d%d%d%d", &company[0][i], &company[1][i], &company[2][i], &company[3][i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.c:72:17: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   72 |                 scanf("%d%d%d", &human[0][i], &human[1][i], &human[2][i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 4
TLE × 8
RE × 12
Set Name Test Cases
All 10-random-00.txt, 10-random-01.txt, 10-random-02.txt, 10-random-03.txt, 10-random-04.txt, 20-absW-00.txt, 20-absW-01.txt, 20-absW-02.txt, 20-absW-03.txt, 20-absW-04.txt, 30-balance-00.txt, 30-balance-01.txt, 30-balance-02.txt, 30-balance-03.txt, 30-balance-04.txt, 40-limit_dim-00.txt, 40-limit_dim-01.txt, 40-limit_dim-02.txt, 40-limit_dim-03.txt, 40-limit_dim-04.txt, 40-limit_dim-05.txt, 40-limit_dim-06.txt, Corner1.txt, Sample1.txt
Case Name Status Exec Time Memory
10-random-00.txt RE 279 ms 257512 KB
10-random-01.txt AC 5 ms 1908 KB
10-random-02.txt TLE 2205 ms 2156 KB
10-random-03.txt TLE 2205 ms 2432 KB
10-random-04.txt RE 266 ms 256768 KB
20-absW-00.txt RE 275 ms 257460 KB
20-absW-01.txt AC 5 ms 1908 KB
20-absW-02.txt RE 268 ms 256940 KB
20-absW-03.txt RE 268 ms 257044 KB
20-absW-04.txt TLE 2205 ms 2116 KB
30-balance-00.txt RE 273 ms 257464 KB
30-balance-01.txt AC 5 ms 1904 KB
30-balance-02.txt RE 262 ms 256364 KB
30-balance-03.txt RE 269 ms 257084 KB
30-balance-04.txt TLE 2205 ms 2316 KB
40-limit_dim-00.txt TLE 2205 ms 2940 KB
40-limit_dim-01.txt RE 273 ms 257360 KB
40-limit_dim-02.txt TLE 2205 ms 2940 KB
40-limit_dim-03.txt RE 275 ms 257516 KB
40-limit_dim-04.txt RE 274 ms 257440 KB
40-limit_dim-05.txt TLE 2205 ms 3092 KB
40-limit_dim-06.txt RE 274 ms 257448 KB
Corner1.txt TLE 2205 ms 1708 KB
Sample1.txt AC 6 ms 1904 KB