結果

問題 No.216 FAC
コンテスト
ユーザー Haijinn
提出日時 2017-02-01 15:12:36
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 575 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 214 ms
コンパイル使用メモリ 33,440 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 16:08:48
合計ジャッジ時間 867 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:21:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |         scanf("%d",&n);
      |         ^~~~~~~~~~~~~~
main.c:24:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 scanf("%d",&a[i]);
      |                 ^~~~~~~~~~~~~~~~~
main.c:27:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |                 scanf("%d",&b[f]);
      |                 ^~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include<stdlib.h>
int main(void)
{
	int n;
	int a[100];
	int b[100];
	int i;
	int q[100];
	int f;
	int d;
	int j=0;
	int k=0;
	int r=0;
	int x=0;
	for(i=0;i<100;i++){
		q[i]=0;
		
	}
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(f=0;f<n;f++){
		scanf("%d",&b[f]);
	}
		
for(i=0;i<n;i++){
	if(b[i]==0){
		r+=a[i];
	}else{
		q[b[i]-1]+=a[i];
		//printf("!%d\n",q[b[i]]);
	}
}
for(i=0;i<100;i++){
	if(q[i]>r){
		
		x++;
		//printf("!%d>%d\n",q[i],r);
	}
	
	
	
}
if(x<1){
	
	printf("YES\n");
	
}else{
	
	printf("NO\n");
}
	
	return 0;
}
0