提出 #77523669


ソースコード 拡げる

Copy
#include <stdio.h>
#include <inttypes.h>
#define N_MAX 212345
#define TIME_MAX 1123456
int N, D;
int S[N_MAX], T[N_MAX];
int candidates[TIME_MAX];
int main(void) {
int i;
uint64_t ans = 0;
if (scanf("%d%d", &N, &D) != 2) return 1;
for (i = 0; i < N; i++) {
if (scanf("%d%d", &S[i], &T[i]) != 2) return 1;
if (S[i] + D <= T[i]) {
candidates[S[i]]++;
candidates[T[i] - D + 1]--;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <inttypes.h>

#define N_MAX 212345
#define TIME_MAX 1123456

int N, D;
int S[N_MAX], T[N_MAX];

int candidates[TIME_MAX];

int main(void) {
	int i;
	uint64_t ans = 0;
	if (scanf("%d%d", &N, &D) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d%d", &S[i], &T[i]) != 2) return 1;
		if (S[i] + D <= T[i]) {
			candidates[S[i]]++;
			candidates[T[i] - D + 1]--;
		}
	}
	for (i = 1; i < TIME_MAX; i++) {
		candidates[i] += candidates[i - 1];
	}
	for (i = 0; i < TIME_MAX; i++) {
		ans += (uint64_t)candidates[i] * (candidates[i] - 1) / 2;
	}
	printf("%" PRIu64 "\n", ans);
	return 0;
}

/*

「それぞれの人が犯行開始できる時刻」をいもす

*/

提出情報

提出日時
問題 D - Accomplice
ユーザ mikecat
言語 C23 (GCC 14.2.0)
得点 400
コード長 731 Byte
結果 AC
実行時間 24 ms
メモリ 7732 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 23
セット名 テストケース
Sample sample-01.txt, sample-02.txt, sample-03.txt
All 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, sample-01.txt, sample-02.txt, sample-03.txt
ケース名 結果 実行時間 メモリ
04.txt AC 3 ms 6196 KiB
05.txt AC 3 ms 6196 KiB
06.txt AC 18 ms 7676 KiB
07.txt AC 18 ms 7552 KiB
08.txt AC 18 ms 7676 KiB
09.txt AC 17 ms 7552 KiB
10.txt AC 15 ms 7552 KiB
11.txt AC 3 ms 6092 KiB
12.txt AC 3 ms 6016 KiB
13.txt AC 3 ms 6004 KiB
14.txt AC 9 ms 6424 KiB
15.txt AC 17 ms 7116 KiB
16.txt AC 20 ms 7604 KiB
17.txt AC 24 ms 7552 KiB
18.txt AC 23 ms 7608 KiB
19.txt AC 19 ms 7456 KiB
20.txt AC 23 ms 7448 KiB
21.txt AC 24 ms 7732 KiB
22.txt AC 23 ms 7604 KiB
23.txt AC 22 ms 7732 KiB
sample-01.txt AC 3 ms 6112 KiB
sample-02.txt AC 3 ms 6068 KiB
sample-03.txt AC 3 ms 6056 KiB


2026-07-16 (木)
19:17:26 +09:00