Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long n,k;
cin>>n>>k;
vector<long long>v(n);
for(int i=0;i<n;i++)
{
cin>>v[i];
}
vector<string>ans;
for(int i=0;i<n;i++)
{
int l=i-1;
int r=i+1;
string temp=to_string(v[i]);
long long op=0;
while(true)
{
long long maxxl=-1;
long long maxxr=-1;
if(op>=k)
break;
if(l>=0)
{
maxxl=v[l];
//l--;
}
if(r<=n-1)
{
maxxr=v[r];
//r++;
}
long long p=max(maxxl,maxxr);
if(p==-1)
break;
if(p==maxxl)
l--;
else if(p==maxxr)
r++;
string hey=to_string(p);
temp+=hey;
// if(i==2)
// cout<<temp<<endl;
op++;
}
ans.push_back(temp);
}
sort(ans.begin(),ans.end());
reverse(ans.begin(),ans.end());
cout<<ans[0]<<endl;
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1083 Number concatenation
- Contest
- Bangladesh 2.0
- Language
- C++11 (G++ 13.2.0)
- Submit At
- 2024-08-16 16:09:19
- Judged At
- 2024-11-11 03:15:52
- Judged By
- Score
- 20
- Total Time
- 27ms
- Peak Memory
- 5.352 MiB