結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2015-07-24 09:40:49 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 454 bytes |
コンパイル時間 | 553 ms |
コンパイル使用メモリ | 20,352 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-08 12:50:34 |
合計ジャッジ時間 | 1,244 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 8 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d %d %d", &A, &B, &S); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> int abs(int a){ if(a < 0){return -1*a;} return a; } int main(void){ int A,B,S; int ans = 0; scanf("%d %d %d", &A, &B, &S); if(S == 1){ ans += abs(S-A); ans += 1; }else{ if(abs(S-A) <= abs(S-B)){ ans += abs(S-A); ans += S; }else{ ans += abs(S-B); if(abs(S-A) <= abs(S-1) ){ ans += abs(S-A); ans += A; }else{ ans += abs(S-1); ans += 1; } } } printf("%d\n", ans); return 0; }