/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 12ms 564.0 KiB
#3 Accepted 11ms 568.0 KiB
#4 Accepted 9ms 548.0 KiB
#5 Accepted 9ms 552.0 KiB
#6 Accepted 9ms 560.0 KiB
#7 Accepted 9ms 572.0 KiB
#8 Accepted 2ms 780.0 KiB
#9 Accepted 2ms 548.0 KiB
#10 Accepted 9ms 572.0 KiB
#11 Accepted 2ms 328.0 KiB
#12 Accepted 4ms 548.0 KiB
#13 Accepted 5ms 556.0 KiB
#14 Accepted 4ms 324.0 KiB
#15 Accepted 8ms 556.0 KiB

Code

#include <iostream>
#include <cstdio>
#include<list>
#include<iomanip>
#include<cmath>
#include<queue>
#include <functional>
#include<stdio.h>
#include<assert.h>
#include<stack>
#include<sstream>
#include <cstdlib>
#include<map>
#include<algorithm>
#include<set>
#include<utility>
#include<memory.h>
#include<string>
#include<vector>
#include<numeric>
#include <bitset>
using namespace std;
#define ll  long long
#define pb push_back
#define fi(ss) freopen (ss,"r",stdin)
#define fo(ss) freopen (ss,"w",stdout)
#define sz(v)               ((ll)((v).size()))
#define all(x)          (x).begin(),(x).end()
#define rep(i, v)       for(ll i=0;i<sz(v);i++)
#define lp(i,n) for(ll i = 0 ; i < n ; ++i)
#define lpab(i, a, b) for(ll i = a; i <= b; i++)
#define lpba(i, b, a) for(ll i = b; i >= a; i--)
#define hash ___hash
#define next ___next
#define prev ___prev
#define left ___left
#define time __time
typedef pair<ll, ll> pii;
#define F first
#define S second
#define MP make_pair
#define vi vector<ll>
#define vvi vector<vi>
#define vpii vector<pii>
#define mpii map<ll, ll> 
#define mpsi map<string, ll>
#define vs vector<string>
#define ld long double
#define vd vector<ld>
#define pie acos(-1)
const ll maxn = 4 * 100005;
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define txtio   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define OO 1e18

ll comp(string & s1, string & s2)
{
	if (sz(s1) > sz(s2))
		return 0;
	if (sz(s2) > sz(s1))
		return 1;
	rep(i, s1)
	{
		if (s1[i] > s2[i])
			return 0;
		if (s2[i] > s1[i])
			return 1;
	}
	return 0;
}

int main()
{
	ll t;
	cin >> t;
	while (t--)
	{
		ll n, k;
		cin >> n >> k;
		vi v(n);
		lp(i, n)
			cin >> v[i];
		string ans = "0";
		lpab(i, 0, n - k - 1)
		{
			string s = "";
			lpab(j, i, i + k)
			{
				s += to_string(v[j]);
			}
			if (comp(ans, s))
				ans = s;
		}
		cout << ans << endl;
	}
	return 0;
}

Information

Submit By
Type
Submission
Problem
P1083 Number concatenation
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-04 18:20:00
Judged At
2024-11-11 03:04:24
Judged By
Score
100
Total Time
12ms
Peak Memory
780.0 KiB