結果

問題 No.216 FAC
コンテスト
ユーザー Tsu0664
提出日時 2015-06-10 18:55:43
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 476 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 131 ms
コンパイル使用メモリ 29,768 KB
最終ジャッジ日時 2026-02-23 18:33:09
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         fscanf(stdin, "%d", &n);
      |         ^~~~~~~~~~~~~~~~~~~~~~~
main.c:9:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 fscanf(stdin, "%d", &a[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:12:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 fscanf(stdin, "%d", &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>

int main(void) {
	int a[100], b[100], s[101];
	int n, i, max = 0, k = 0;
	
	fscanf(stdin, "%d", &n);
	for(i = 0; i < n; i++)
		fscanf(stdin, "%d", &a[i]);
		
	for(i =0; i < n; i++)
		fscanf(stdin, "%d", &b[i]);
		
	for(i =0; i <= n; i++)
		s[i] = 0;
		
	for(i = 0; i < n; i++){
		if(!(b[i])){
			k += a[i];
		}else{
			s[b[i]] += a[i];
			if(max < s[b[i]])
				max = s[b[i]];
		}
	}
	
	if(k >= max)
		printf("YES\n");
	else
		printf("NO\n");
	
	return 0;
}
0