結果
問題 |
No.126 2基のエレベータ
|
ユーザー |
![]() |
提出日時 | 2015-07-24 09:43:13 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 475 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 18:27:11 |
合計ジャッジ時間 | 1,307 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
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 += abs(A-1); ans += 1; } } } printf("%d\n", ans); return 0; }