Submission #16498641


Source Code Expand

Copy
#include <stdio.h>

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

        for (i = 0; i < n; i++)
        {
                for (j = n - 1; j > i; j--)
                {
                        if (company[3][j - 1] < company[3][j])
                        {
                                for (k = 0; k < 4; k++)
                                {
                                        temp = company[k][j];
                                        company[k][j] = company[k][j - 1];
                                        company[k][j - 1] = temp;
                                }
                        }
                }
        }
}

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]);
        }
        sort_company(company, 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 2088 Byte
Status TLE
Exec Time 2205 ms
Memory 3048 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:49:9: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   49 |         scanf("%d%d", &n, &m);
      |         ^~~~~~~~~~~~~~~~~~~~~
./Main.c:52:17: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   52 |                 scanf("%d%d%d%d", &company[0][i], &company[1][i], &company[2][i], &company[3][i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.c:56:17: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   56 |                 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 × 10
TLE × 14
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 TLE 2205 ms 2948 KB
10-random-01.txt AC 7 ms 1904 KB
10-random-02.txt AC 42 ms 2304 KB
10-random-03.txt AC 559 ms 2632 KB
10-random-04.txt TLE 2205 ms 2312 KB
20-absW-00.txt TLE 2205 ms 3044 KB
20-absW-01.txt AC 6 ms 1940 KB
20-absW-02.txt TLE 2205 ms 2672 KB
20-absW-03.txt TLE 2205 ms 2628 KB
20-absW-04.txt AC 514 ms 2316 KB
30-balance-00.txt TLE 2205 ms 2948 KB
30-balance-01.txt AC 5 ms 1960 KB
30-balance-02.txt AC 31 ms 2180 KB
30-balance-03.txt TLE 2205 ms 2552 KB
30-balance-04.txt AC 82 ms 2472 KB
40-limit_dim-00.txt TLE 2205 ms 3016 KB
40-limit_dim-01.txt TLE 2205 ms 2932 KB
40-limit_dim-02.txt TLE 2205 ms 3036 KB
40-limit_dim-03.txt TLE 2205 ms 2940 KB
40-limit_dim-04.txt TLE 2205 ms 3020 KB
40-limit_dim-05.txt TLE 2205 ms 3048 KB
40-limit_dim-06.txt TLE 2205 ms 3016 KB
Corner1.txt AC 7 ms 1900 KB
Sample1.txt AC 1 ms 1952 KB