結果
| 問題 | No.801 エレベーター |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-07-17 08:23:42 |
| 言語 | C (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 2,000 ms |
| コード長 | 971 bytes |
| 記録 | |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 30,720 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-17 17:20:41 |
| 合計ジャッジ時間 | 2,269 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.c: In function 'in':
main.c:8:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
8 | #define gc() getchar_unlocked()
| ^~~~~~~~~~~~~~~~
main.c:13:24: note: in expansion of macro 'gc'
13 | int n = 0, c = gc();
| ^~
ソースコード
// yukicoder: No.801 エレベーター
// 2019.7.17 bal4u
#include <stdio.h>
#include <string.h>
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in() { // 非負整数の入力
int n = 0, c = gc();
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
typedef long long ll;
#define MOD 1000000007
int L[3003], R[3003];
ll dp[2][3003], *cur, *nxt, *t;
int main()
{
int i, j, N, M, K, N1, ans;
N = in(), M = in(), K = in(), N1 = N+1;
for (i = 0; i < M; i++) L[i] = in(), R[i] = in();
dp[0][1] = 1, cur = dp[0], nxt = dp[1];
for (i = 0; i < K; i++) {
for (j = 1; j <= N1; j++) cur[j] += cur[j-1];
for (j = 0; j < M; j++) {
ll t = cur[R[j]] - cur[L[j]-1];
nxt[L[j]] += t, nxt[R[j]+1] -= t;
}
for (j = 1; j <= N1; j++) nxt[j] = (nxt[j] + nxt[j-1]) % MOD;
t = cur, cur = nxt, nxt = t;
memset(nxt, 0, sizeof(dp[0]));
}
ans = cur[N]; if (ans < 0) ans += MOD;
printf("%d\n", ans);
return 0;
}
bal4u