結果

問題 No.801 エレベーター
ユーザー 34056915823405691582
提出日時 2019-03-25 19:55:20
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,236 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 11:16:16
合計ジャッジ時間 2,383 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 43 ms
6,944 KB
testcase_14 AC 43 ms
6,944 KB
testcase_15 AC 43 ms
6,944 KB
testcase_16 AC 42 ms
6,944 KB
testcase_17 AC 42 ms
6,940 KB
testcase_18 AC 43 ms
6,940 KB
testcase_19 AC 43 ms
6,940 KB
testcase_20 AC 44 ms
6,944 KB
testcase_21 AC 46 ms
6,940 KB
testcase_22 AC 43 ms
6,940 KB
testcase_23 AC 44 ms
6,944 KB
testcase_24 AC 42 ms
6,944 KB
testcase_25 AC 43 ms
6,944 KB
testcase_26 AC 43 ms
6,940 KB
testcase_27 AC 42 ms
6,940 KB
testcase_28 AC 42 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int n,m,k;
  long int sum;
  scanf("%d%d%d",&n,&m,&k);
  int l[m],r[m];
  for(int i=0;i<m;i++) scanf("%d%d",&l[i],&r[i]);
  long int *p,*pp,*temp;
  p = malloc(sizeof(long int)*n);
  pp = malloc(sizeof(long int)*n);
  for(int i=0;i<n;i++) p[i]=0;
  p[0]=1;
  for(int i=0;i<k;i++){
    temp=p;p=pp;pp=temp;
    for(int j=0;j<n;j++)p[j]=0;
    for(int j=1;j<n;j++)pp[j]+=pp[j-1];
    for(int j=0;j<m;j++){
      sum=pp[r[j]-1]-(l[j]>1?pp[l[j]-2]:0);
      p[l[j]-1]+=sum;
      if(r[j]<n)p[r[j]]-=sum;
    }
    for(int j=1;j<n;j++)p[j]+=p[j-1];
    for(int j=0;j<n;j++)p[j]%=1000000007;
  }
  printf("%d\n",p[n-1]);
  free(p);
  free(pp);
  return 0;
}
0