Submission #75829


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int x,l,r;
cin>>x>>l>>r;
int sa=INT_MAX,san=0;
for(int i=l;i<=r;i++){
if(sa>abs(i-x)){
sa=abs(x-i);
san=i;
}
}
cout<<san<<"\n";
return 0;
}

ステータス

項目 データ
問題 1426 - X に最も近い値
ユーザー名 ei2331
投稿日時 2023-09-08 17:35:30
言語 C++17
状態 Accepted
得点 100
ソースコード長 302 Byte
最大実行時間 28 ms
最大メモリ使用量 676 KB

セット

セット 得点 Cases
1 ALL 100 / 100 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
01-01.txt AC 25 ms 604 KB
1
01-02.txt AC 21 ms 444 KB
1
01-03.txt AC 22 ms 544 KB
1
01-04.txt AC 21 ms 520 KB
1
01-05.txt AC 24 ms 616 KB
1
01-06.txt AC 19 ms 588 KB
1
01-07.txt AC 28 ms 556 KB
1
01-08.txt AC 21 ms 524 KB
1
01-09.txt AC 22 ms 500 KB
1
01-10.txt AC 27 ms 468 KB
1
01-11.txt AC 20 ms 444 KB
1
01-12.txt AC 23 ms 412 KB
1
01-13.txt AC 24 ms 512 KB
1
01-14.txt AC 21 ms 616 KB
1
01-15.txt AC 20 ms 592 KB
1
01-16.txt AC 27 ms 560 KB
1
01-17.txt AC 25 ms 532 KB
1
01-18.txt AC 22 ms 500 KB
1
01-19.txt AC 16 ms 600 KB
1
01-20.txt AC 18 ms 576 KB
1
sample-01.txt AC 26 ms 676 KB
1
sample-02.txt AC 20 ms 644 KB
1
sample-03.txt AC 22 ms 492 KB
1