/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 27ms 5.352 MiB
#3 Accepted 26ms 4.836 MiB
#4 Wrong Answer 26ms 4.824 MiB
#5 Accepted 24ms 4.758 MiB
#6 Wrong Answer 24ms 4.898 MiB

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