結果

問題 No.709 優勝可能性
コンテスト
ユーザー bal4u
提出日時 2019-08-04 07:21:33
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 32 ms / 3,500 ms
コード長 1,018 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 205 ms
コンパイル使用メモリ 40,004 KB
最終ジャッジ日時 2026-02-22 04:04:57
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// yukicoder: No.709 優勝可能性
// 2019.8.4 bal4u

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

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

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

void out(int n) { // 正整数の表示(出力)
	int i;
	char b[20];

	i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
	pc('\n');
}

int N, M;
char f[100005]; int ans;
int ma[12], list[12][100005], sz[12];

int main()
{
	int i, n, m, r;

	N = in(), M = in();
	for (n = 0; n < N; n++) {
		for (m = 0; m < M; m++) {
			r = in();
			if (r > ma[m]) {
				for (i = 0; i < sz[m]; i++) {
					if (--f[list[m][i]] == 0) ans--;
				}
				ma[m] = r, list[m][0] = n, sz[m] = 1;
				if (f[n] == 0) ans++;
				f[n]++;
			} else if (r == ma[m]) {
				list[m][sz[m]++] = n;
				if (f[n] == 0) ans++;
				f[n]++;
			}
		}
		out(ans);
	}
	return 0;
}
0