結果

問題 No.561 東京と京都
ユーザー sasa
提出日時 2025-03-11 10:24:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 27,392 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-11 10:24:55
合計ジャッジ時間 1,507 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 6 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d%d",&workday,&expense);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:16:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |                 scanf("%d%d",&tokyoSalary,&kyotoSalary);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

int main(void){
	// 仕事日数・移動交通費
	int workday,expense;
	scanf("%d%d",&workday,&expense);
	//trueなら東京・falseなら京都
	bool locationflg = true;
	// 合計給料
	int total = 0;
	
	for(int i = 0;i < workday;i++){
		// 東京給料・京都給料
		int tokyoSalary,kyotoSalary;
		scanf("%d%d",&tokyoSalary,&kyotoSalary);	
		if(locationflg == true){
			if((kyotoSalary - expense) > tokyoSalary){
				total += (kyotoSalary - expense);
			}else{
				total += tokyoSalary;
			}
		}else{
			if((tokyoSalary - expense) > kyotoSalary){
				total += (tokyoSalary - expense);
			}else{
				total += kyotoSalary;
			}
		}
	}
	printf("%d",total);
}
0