20012022-12-13 20:20:15KovácsHunorForma-1cpp11Wrong answer 0/1002.099s3928 KiB
#include "stdio.h"
#include "stdlib.h"

void QuickSort(unsigned long long* arr, int size){
    int pivot = 0;
    for (int i = 1; i < size; i++)
    {
        if(arr[pivot] < arr[i]){
            arr[pivot] ^= arr[pivot+1];
            arr[pivot+1] ^= arr[pivot];
            arr[pivot] ^= arr[pivot+1];
            pivot++;

            if(i != pivot){
                arr[pivot-1] ^= arr[i];
                arr[i] ^= arr[pivot-1];
                arr[pivot-1] ^= arr[i];
            }
        }
    }
    if(pivot > 1)        QuickSort(arr, pivot);
    if(pivot < size-2) QuickSort(arr + (pivot+1), size - (pivot+1) );
}

unsigned long long distance(unsigned long long a, unsigned long long b, unsigned long long c, unsigned long long t){
    return t*t*a + t*b + c;
}

int main()
{
    int n, q;
    scanf("%d", &n);
    int* arr = (int*)malloc(sizeof(int)*n*3);
    for (int i = 0; i < n; i++)
    {
        scanf("%d%d%d", arr + i, arr + i + n, arr + i + 2*n);
    }
    scanf("%d", &q);
    int* sol = (int*)malloc(sizeof(int)*q);
    unsigned long long* dis = (unsigned long long*)malloc(sizeof(unsigned long long)*n);

    for (int i = 0; i < q; i++)
    {
        int p, t;
        scanf("%d%d", &p, &t);
        for (int j = 0; j < n; j++)
        {
            dis[j] = distance(arr[j], arr[j+n], arr[j+2*n], t)*10000 + n-j; 
        }

        QuickSort(dis, n);
        sol[i] = n - dis[p-1]%10000 + 1;
    }
    for (int i = 0; i < q; i++)
    {
        printf("%d\n", sol[i]);
    }
    free(arr);
    free(sol);
    free(dis);
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1428 KiB
subtask20/20
2Accepted75ms2908 KiB
3Accepted75ms3112 KiB
4Accepted75ms3320 KiB
5Accepted72ms3352 KiB
6Accepted75ms3484 KiB
7Accepted72ms3588 KiB
8Wrong answer78ms3668 KiB
9Wrong answer86ms3764 KiB
subtask30/30
10Accepted1.707s2804 KiB
11Accepted1.819s2848 KiB
12Time limit exceeded2.059s3024 KiB
13Time limit exceeded2.075s3208 KiB
14Time limit exceeded2.079s2820 KiB
15Time limit exceeded2.043s3064 KiB
16Time limit exceeded2.075s3404 KiB
17Time limit exceeded2.048s3676 KiB
18Time limit exceeded2.086s3760 KiB
subtask40/50
19Time limit exceeded2.072s3392 KiB
20Time limit exceeded2.063s3108 KiB
21Time limit exceeded2.049s3364 KiB
22Time limit exceeded2.072s3480 KiB
23Time limit exceeded2.016s3564 KiB
24Time limit exceeded2.099s3804 KiB
25Time limit exceeded2.052s3388 KiB
26Time limit exceeded2.081s3780 KiB
27Time limit exceeded2.065s3656 KiB
28Time limit exceeded2.079s3692 KiB
29Time limit exceeded2.076s3744 KiB
30Time limit exceeded2.081s3928 KiB