結果
| 問題 |
No.149 碁石の移動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-23 23:00:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 538 bytes |
| コンパイル時間 | 300 ms |
| コンパイル使用メモリ | 30,336 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 03:27:52 |
| 合計ジャッジ時間 | 811 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d %d", &Aw, &Ab);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d %d", &Bw, &Bb);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d %d", &C, &D);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(int argc, char *argv[])
{
int Aw = 0;
int Ab = 0;
int Bw = 0;
int Bb = 0;
int C = 0;
int D = 0;
scanf("%d %d", &Aw, &Ab);
scanf("%d %d", &Bw, &Bb);
scanf("%d %d", &C, &D);
if( C >= Ab )
{
Bb += Ab;
Bw += (C - Ab);
Aw -= (C - Ab);
Ab = 0;
}
else
{
Bb += C;
Ab -= C;
}
if (D >= Bw)
{
Aw += Bw;
Ab += (D - Bw);
Bb -= (D - Bw);
Bw = 0;
}
else
{
Aw += D;
Bw -= D;
}
printf("%d\n", Aw);
return 0;
}