結果

問題 No.1535 五七五
ユーザー bal4ubal4u
提出日時 2021-08-14 22:05:22
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 19:36:27
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// yukicoder: 1535 五七五
// 2021.8.14

#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int getchar_unlocked(void);
#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int ins(char *s) { // 文字列の入力 スペース以下の文字で入力終了
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

int s[500005]; int N;

bool bs(int l, int r, int x) {
	while (l+1 < r) {
		int m = (l+r) >> 1;
		if (s[m] == x) return true;
		if (s[m] < x) l = m; else r = m;
	}
	return s[l] == x;
}

int main() {
	int i, l, m, r, t, a, b, c;
	char tmp[20];
	int ans = 0;

	N = in(), a = in(), b = in(), c = in();
	for (i = 0; i < N; ++i) s[i+1] = s[i] + ins(tmp);
	l = 0, m = 1, r = 2; while (r <= N) {
		while (r <= N && s[r]-s[l] < a+b+c) r++;
		if (r > N) break;
		while (l < r && s[r]-s[l] > a+b+c) { l++; continue; }
		if (l == r) continue;
		if (bs(l, r, s[l]+a) && bs(l, r, s[l]+a+b)) ans++;
		l++;
	}
	printf("%d\n", ans);
	return 0;
}
0