結果

問題 No.561 東京と京都
ユーザー sasa
提出日時 2025-03-11 10:33:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,275 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 28,544 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-11 10:33:42
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘int’ [-Wformat=]
   18 |                 scanf("%d%d",tokyoSalary[i],kyotoSalary[i]);
      |                        ~^    ~~~~~~~~~~~~~~
      |                         |                 |
      |                         int*              int
main.cpp:18:27: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int’ [-Wformat=]
   18 |                 scanf("%d%d",tokyoSalary[i],kyotoSalary[i]);
      |                          ~^                 ~~~~~~~~~~~~~~
      |                           |                              |
      |                           int*                           int
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:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                 scanf("%d%d",tokyoSalary[i],kyotoSalary[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

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;
	// 東京の日給
	int tokyoSalary[workday];
	// 京都の日給
	int kyotoSalary[workday];
	
	for(int i = 0;i < workday;i++){
		scanf("%d%d",tokyoSalary[i],kyotoSalary[i]);
	}
	
	for(int i = 0;i < workday;i++){	
		if(locationflg == true){
			if((kyotoSalary[i] - expense) > tokyoSalary[i]){
				total += (kyotoSalary[i] - expense);
			}else if((kyotoSalary[i] - expense) < tokyoSalary[i]){
				total += tokyoSalary[i];
			}else if((kyotoSalary[i] - expense) == tokyoSalary[i]){
				if(kyotoSalary[i] > tokyoSalary[i]){
					total += (kyotoSalary[i] - expense);
				}else{
					total += tokyoSalary[i];
				}
			}
		}else{
			if((tokyoSalary[i] - expense) > kyotoSalary[i]){
				total += (tokyoSalary[i] - expense);
			}else if((tokyoSalary[i] - expense) < kyotoSalary[i]){
				total += kyotoSalary[i];
			}else if((tokyoSalary[i] - expense) == kyotoSalary[i]){
				if(tokyoSalary[i] > kyotoSalary[i]){
					total += (tokyoSalary[i] - expense);
				}else{
					total += kyotoSalary[i];
				}
			}
		}
	}
	printf("%d",total);
}
0