結果

問題 No.647 明太子
ユーザー onakaT_TitaionakaT_Titai
提出日時 2018-02-09 22:38:54
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 37 ms / 4,500 ms
コード長 2,288 bytes
コンパイル時間 722 ms
コンパイル使用メモリ 30,780 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 09:23:34
合計ジャッジ時間 1,425 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 4 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 35 ms
4,380 KB
testcase_18 AC 37 ms
4,376 KB
testcase_19 AC 5 ms
4,384 KB
testcase_20 AC 5 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


int descending_compare(const void *a, const void *b){
    if (*(long long*)a > *(long long*)b){
        return -1;
    }else if (*(long long*)a == *(long long*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

//greatest common divisor
unsigned long  gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

/*
int struct_ascending_compare(const void *p, const void *q) {
    return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/

int a[10005];
int b[10005];
int x[1005];
int y[1005];
int mentaiko[1005] = {0};

int main(void){
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++){
        scanf("%d %d", &x[i], &y[i]);
    }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (x[j] <= a[i] && y[j] >= b[i]){
                mentaiko[j]++;
            }
        }
    }
    int max = -1;
    for (int i = 0; i < m; i++){
        if (max < mentaiko[i]){
            max = mentaiko[i];
        }
    }
    if (max == 0){
        printf("0\n");
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < m; i++){
        if (mentaiko[i] == max){
            printf("%d\n", i+1);
        }
    }
    return 0;




}
0