結果
| 問題 |
No.126 2基のエレベータ
|
| コンテスト | |
| ユーザー |
MoritaYasuaki
|
| 提出日時 | 2016-05-09 02:07:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 423 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 23,808 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-05 13:01:37 |
| 合計ジャッジ時間 | 916 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 WA * 4 |
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
18 | main(){
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%td%td%td\n", &A,&B,&S);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#define int ptrdiff_t
#define div lldiv
#define div_t lldiv_t
#define abs(a) ((a)<0?-(a):(a))
int A,B,S;
int calc(void) {
if (S == 1 || abs(A-S) <= abs(B-S))
return abs(A-S) + abs(S-0);
return abs(B-S) + abs(S-1) + abs(A-1) + abs(1-0);
}
main(){
int ans = 0;
scanf("%td%td%td\n", &A,&B,&S);
printf("%td\n", calc());
return 0;
}
MoritaYasuaki