Submission #2215709


Source Code Expand

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

#define FOR(i, a, b) for(i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define comp(a, b) int comp(const void *a, const void *b)
#define MOD  1000000007

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

void TF_print(char boolean, char T[], char F[]){
    if(boolean){
        printf("%s\n", T);
    }else{
        printf("%s\n", F);
    }
}

comp(a, b){
    ll diff = *(ll*)a - *(ll*)b;
    if(diff > 0){
        return 1;
    }else if(diff < 0){
        return -1;
    }else{
        return 0;
    }
}

int main(){
    ll N, b;
    ll i;
    scanf("%lld", &N);
    ll A[N], B[N], C[N], temp;
    ll A_less_B[N];// A[i] < B[n]なるiの個数
    ll C_big_B[N]; // B[n] < C[i]なるiの個数

    REP(b, 3){
        REP(i, N){
            scanf("%lld", &temp);
            if(b == 0) A[i] = temp;
            if(b == 1) B[i] = temp;
            if(b == 2) C[i] = temp;
        }

        if(b == 0) qsort(A, N, sizeof(ll), comp);
        if(b == 1) qsort(B, N, sizeof(ll), comp);
        if(b == 2) qsort(C, N, sizeof(ll), comp);
    }

    REP(b, N){
        A_less_B[b] = N;                   
        REP(i, N){
            if(A[i] >= B[b]){
                A_less_B[b] = i;
                break;
            }
        }
    }

    REP(b, N){
        C_big_B[b] = N;
        REP(i, N){
            if(C[N - 1 - i] <= B[b]){
                C_big_B[b] = i;
                break;
            }
        }
    }

    ll ANS = 0;
    REP(b, N){
        ANS += A_less_B[b] * C_big_B[b];
    }

    printf("%lld\n", ANS);
    return 0;
}

/*
3数の大小関係は真ん中を基準にすると良い. 4, 5と増えても同じではなかろうか.
*/

Submission Info

Submission Time
Task C - Snuke Festival
User kumachan_atcoder
Language C (GCC 5.4.1)
Score 0
Code Size 1860 Byte
Status TLE
Exec Time 2103 ms
Memory 4844 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:37:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &N);
     ^
./Main.c:44:13: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld", &temp);
             ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 10
TLE × 22
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt TLE 2103 ms 4204 KB
02.txt TLE 2103 ms 4332 KB
03.txt TLE 2103 ms 4460 KB
04.txt TLE 2103 ms 3948 KB
05.txt TLE 2103 ms 4076 KB
06.txt TLE 2103 ms 4204 KB
07.txt TLE 2103 ms 3952 KB
08.txt TLE 2103 ms 4080 KB
09.txt TLE 2103 ms 3988 KB
10.txt TLE 2103 ms 3988 KB
11.txt TLE 2103 ms 4016 KB
12.txt TLE 2103 ms 4016 KB
13.txt TLE 2103 ms 4332 KB
14.txt TLE 2103 ms 4588 KB
15.txt TLE 2103 ms 4460 KB
16.txt TLE 2103 ms 4332 KB
17.txt TLE 2103 ms 3564 KB
18.txt AC 76 ms 4844 KB
19.txt TLE 2103 ms 4460 KB
20.txt TLE 2103 ms 3700 KB
21.txt AC 38 ms 4468 KB
22.txt AC 53 ms 4468 KB
23.txt TLE 2103 ms 4076 KB
24.txt TLE 2103 ms 4080 KB
25.txt TLE 2103 ms 3948 KB
26.txt AC 1 ms 128 KB
27.txt AC 0 ms 128 KB
28.txt AC 1 ms 128 KB
29.txt AC 0 ms 128 KB
s1.txt AC 0 ms 128 KB
s2.txt AC 0 ms 128 KB
s3.txt AC 1 ms 128 KB