hihoCoder太阁最新面经算法竞赛18 register

Ended

Participants:65

Verdict:Accepted
Score:100 / 100
Submitted:2016-12-12 19:39:18

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
int a[50010];
set<pair<int,int>> s;
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
        int n,k;
        cin>>n>>k;
        s.clear();
        for (int i=0;i<n;i++)
        {
            cin>>a[i];
            s.insert({a[i],i});
        }
        if (n%k)
        {
            puts("NO");
            continue;
        }
        for (int i=0;i<n/k;i++)
        {
            int pre=s.begin()->first;
            s.erase(s.begin());
            //cout<<pre<<endl;
            for (int j=1;j<k;j++)
            {
                auto o=s.lower_bound({pre+1,-1});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX