結果
| 問題 | No.2091 Shio Ramen (Easy) |
| ユーザー |
|
| 提出日時 | 2022-10-06 16:02:56 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 949 bytes |
| 記録 | |
| コンパイル時間 | 1,626 ms |
| コンパイル使用メモリ | 200,132 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 22:14:58 |
| 合計ジャッジ時間 | 2,594 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:48: warning: ‘R’ may be used uninitialized [-Wmaybe-uninitialized]
9 | #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT
| ^~~~
main.cpp:22:7: note: ‘R’ was declared here
22 | int R;
| ^
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr )
#define CIN( LL , A ) LL A; cin >> A
#define TYPE_OF( VAR ) remove_const<remove_reference<decltype( VAR )>::type >::type
#define FOREQ( VAR , INITIAL , FINAL ) for( TYPE_OF( FINAL ) VAR = INITIAL ; VAR <= FINAL ; VAR ++ )
#define QUIT return 0
#define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; QUIT
template <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : - a; }
int main()
{
UNTIE;
CIN( int , N );
assert( 1 <= N && N <= 10 );
CIN( int , S );
assert( 1 <= S && S <= 10 );
CIN( int , K );
assert( 0 <= K && K <= 10 );
int R;
int opt = K + 1;
int opt_current;
int Ai;
FOREQ( i , 1 , N ){
cin >> Ai;
opt_current = Absolute( Ai - S );
if( opt_current < opt ){
R = i;
opt = opt_current;
}
}
if( opt <= K ){
RETURN( R );
}
RETURN( "Unlucky!" );
}