QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#55784 | #1752. Ballpark Estimate | omaradwan | AC ✓ | 6ms | 13112kb | C++ | 1.9kb | 2022-10-15 03:39:57 | 2022-10-15 03:39:58 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define el '\n'
#define pi 3.1415926536
#define mod 1000000007
#include <sstream>
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int const N = 2e5+5;
map<int, int>mp;
map<int, int> freqq;
map<pair<ll, ll>, ll> mpp;
vector<pair<ll,ll>>adj[N],adj2[N];
deque<pair<int,int>>pq2;
//priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<>>pq;
int dx[] = { 1, -1,0, 0 };
int dy[] = { 0,0, 1,-1 };
int chess_x[] = { -1,-1,1,1, 1, -1, 0, 0 ,0};
int chess_y[] = { 1, -1,1,-1, 0,0, 1,-1,0 };
ll a[N];
ll n,ans=0;
int main()
{
fast;
ll n,a[4];cin>>n;
string s;
s= to_string(n);
ll num= s[0]-'0';
while(num<n){
num*=10;
}
string s1= to_string(num);
if(s1.size()>s.size()) {
num /= 10;
}
a[0]=num;
ll num2=s[0]-'0';
if(num2!=1)num2--;
while(num2<n){
num2*=10;
}
string s2= to_string(num2);
if(s2.size()>s.size())
num2/=10;
a[1]=num2;
ll o=0,num3=s[0]-'0';
if(num3==9)o=1;
num3++;
while(num3<n){
num3*=10;
}
string s3= to_string(num3);
if(s3.size()>s.size()) {
num3 /= 10;
}
if(o)a[3]=num3*10;
a[2]=num3;
sort(a,a+4);
// cerr<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3];
if(abs(a[3]-n)<=abs(a[1]-n)&&abs(a[3]-n)<=abs(a[0]-n) && abs(a[3]-n)<=abs(a[2]-n))cout<<a[3]<<el;
else if(abs(a[2]-n)<=abs(a[1]-n)&&abs(a[2]-n)<=abs(a[0]-n) && abs(a[2]-n)<=abs(a[3]-n))cout<<a[2]<<el;
else if(abs(a[1]-n)<=abs(a[0]-n)&&abs(a[1]-n)<=abs(a[2]-n)&&abs(a[1]-n)<=abs(a[3]-n))cout<<a[1]<<el;
else cout<<a[0];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 12936kb
input:
1
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 6ms
memory: 12940kb
input:
533839461958894364
output:
500000000000000000
result:
ok single line: '500000000000000000'
Test #3:
score: 0
Accepted
time: 2ms
memory: 13016kb
input:
253879280762610326
output:
300000000000000000
result:
ok single line: '300000000000000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 13060kb
input:
861411989833943880
output:
900000000000000000
result:
ok single line: '900000000000000000'
Test #5:
score: 0
Accepted
time: 1ms
memory: 12924kb
input:
5
output:
5
result:
ok single line: '5'
Test #6:
score: 0
Accepted
time: 6ms
memory: 13028kb
input:
9
output:
9
result:
ok single line: '9'
Test #7:
score: 0
Accepted
time: 2ms
memory: 13024kb
input:
11
output:
10
result:
ok single line: '10'
Test #8:
score: 0
Accepted
time: 2ms
memory: 12924kb
input:
15
output:
20
result:
ok single line: '20'
Test #9:
score: 0
Accepted
time: 1ms
memory: 12944kb
input:
49
output:
50
result:
ok single line: '50'
Test #10:
score: 0
Accepted
time: 6ms
memory: 13028kb
input:
1497
output:
1000
result:
ok single line: '1000'
Test #11:
score: 0
Accepted
time: 3ms
memory: 12940kb
input:
6583
output:
7000
result:
ok single line: '7000'
Test #12:
score: 0
Accepted
time: 2ms
memory: 12924kb
input:
8967
output:
9000
result:
ok single line: '9000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 12940kb
input:
9758
output:
10000
result:
ok single line: '10000'
Test #14:
score: 0
Accepted
time: 2ms
memory: 12996kb
input:
10772
output:
10000
result:
ok single line: '10000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 13000kb
input:
11644
output:
10000
result:
ok single line: '10000'
Test #16:
score: 0
Accepted
time: 6ms
memory: 12948kb
input:
20851
output:
20000
result:
ok single line: '20000'
Test #17:
score: 0
Accepted
time: 2ms
memory: 12948kb
input:
21166
output:
20000
result:
ok single line: '20000'
Test #18:
score: 0
Accepted
time: 6ms
memory: 12940kb
input:
24183
output:
20000
result:
ok single line: '20000'
Test #19:
score: 0
Accepted
time: 6ms
memory: 13112kb
input:
28860
output:
30000
result:
ok single line: '30000'
Test #20:
score: 0
Accepted
time: 2ms
memory: 12924kb
input:
32184
output:
30000
result:
ok single line: '30000'
Test #21:
score: 0
Accepted
time: 3ms
memory: 13016kb
input:
32325
output:
30000
result:
ok single line: '30000'