結果

問題 No.110 しましまピラミッド
ユーザー akakimidoriakakimidori
提出日時 2017-06-21 01:38:40
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 787 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 24,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 03:59:31
合計ジャッジ時間 1,596 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 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 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 0 ms
4,376 KB
testcase_17 AC 0 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 0 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>

#define MAX(a,b) ((a)>(b)?(a):(b))

int calc(int *a,int n,int *b,int m){
  int res=1;
  int s=n-1;
  int t=m-1;
  while(1){
    while(t>=0 && a[s]<=b[t]) t--;
    if(t<0) return res;
    res++;
    while(s>=0 && b[t]<=a[s]) s--;
    if(s<0) return res;
    res++;
  }
  return 0;
}

void sort(int *a,int n){
  int i,j;
  for(i=1;i<n;i++){
    int p=a[i];
    j=i-1;
    while(j>=0 && p<a[j]){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=p;
  }
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  int w[10];
  int i;
  for(i=0;i<n;i++) scanf("%d",w+i);

  int m;
  scanf("%d",&m);
  int b[10];
  for(i=0;i<m;i++) scanf("%d",b+i);

  sort(w,n);
  sort(b,m);
  printf("%d\n",MAX(calc(w,n,b,m),calc(b,m,w,n)));
  return;
}

int main(void){
  run();
  return 0;
}
0