답안 #90919

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90919 2018-12-25T08:19:52 Z toloraia Gift (IZhO18_nicegift) C++17
30 / 100
97 ms 32400 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 5e5 + 5, INF = 1e9 + 5;

int n, k;
pair < int, int > P[N];
int nn;
vector < int > V[N], v;
int S;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for (int i = 1; i <= n; i++){
        cin>>P[i].F;
        P[i].S = i;
        S += P[i].F;
    }
    sort (P + 1, P + n + 1);
    reverse (P + 1, P + n + 1);
    if (S <= 1e5){
        while (P[k].F > 0){
            int I1 = k, I2 = k;
            for (int i = 20; i >= 0; i--){
                if (I1 - (1<<i) <= 0)
                    continue;
                if (P[I1 - (1<<i)].F == P[k].F)
                    I1 -= (1<<i);
            }
            for (int i = 20; i >= 0; i--){
                if (I2 + (1<<i) > n)
                    continue;
                if (P[I2 + (1<<i)].F == P[k].F)
                    I2 += (1<<i);
            }
            v.clear();
            for (int i = 1; i < I1; i++){
                v.pb (P[i].S);
                P[i].F--;
            }
            for (int i = I2; (int)v.size() < k; i--){
                v.pb (P[i].S);
                P[i].F--;
            }
            V[++nn] = v;
        }
        if (P[1].F > 0){
            cout<<-1<<endl;
            return 0;
        }
        cout<<nn<<endl;
        for (int i = 1; i <= nn; i++){
            cout<<"1 ";
            for (int j = 0; j < k; j++)
                cout<<V[i][j]<<" ";
            cout<<endl;
        }
        return 0;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12024 KB n=4
2 Correct 10 ms 12148 KB n=3
3 Correct 10 ms 12352 KB n=3
4 Correct 10 ms 12352 KB n=4
5 Correct 10 ms 12352 KB n=4
6 Correct 10 ms 12352 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12024 KB n=4
2 Correct 10 ms 12148 KB n=3
3 Correct 10 ms 12352 KB n=3
4 Correct 10 ms 12352 KB n=4
5 Correct 10 ms 12352 KB n=4
6 Correct 10 ms 12352 KB n=2
7 Correct 10 ms 12352 KB n=5
8 Correct 12 ms 12584 KB n=8
9 Correct 32 ms 12844 KB n=14
10 Correct 26 ms 12844 KB n=11
11 Correct 97 ms 15056 KB n=50000
12 Correct 97 ms 15172 KB n=50000
13 Correct 86 ms 15172 KB n=10
14 Correct 75 ms 15172 KB n=685
15 Correct 81 ms 15172 KB n=623
16 Correct 50 ms 15172 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12024 KB n=4
2 Correct 10 ms 12148 KB n=3
3 Correct 10 ms 12352 KB n=3
4 Correct 10 ms 12352 KB n=4
5 Correct 10 ms 12352 KB n=4
6 Correct 10 ms 12352 KB n=2
7 Correct 10 ms 12352 KB n=5
8 Correct 12 ms 12584 KB n=8
9 Correct 32 ms 12844 KB n=14
10 Correct 26 ms 12844 KB n=11
11 Correct 97 ms 15056 KB n=50000
12 Correct 97 ms 15172 KB n=50000
13 Correct 86 ms 15172 KB n=10
14 Correct 75 ms 15172 KB n=685
15 Correct 81 ms 15172 KB n=623
16 Correct 50 ms 15172 KB n=973
17 Correct 61 ms 15172 KB n=989
18 Correct 24 ms 15172 KB n=563
19 Correct 23 ms 15172 KB n=592
20 Correct 26 ms 15172 KB n=938
21 Correct 25 ms 15172 KB n=747
22 Correct 25 ms 15172 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Runtime error 67 ms 32400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12024 KB n=4
2 Correct 10 ms 12148 KB n=3
3 Correct 10 ms 12352 KB n=3
4 Correct 10 ms 12352 KB n=4
5 Correct 10 ms 12352 KB n=4
6 Correct 10 ms 12352 KB n=2
7 Correct 10 ms 12352 KB n=5
8 Correct 12 ms 12584 KB n=8
9 Correct 32 ms 12844 KB n=14
10 Correct 26 ms 12844 KB n=11
11 Correct 97 ms 15056 KB n=50000
12 Correct 97 ms 15172 KB n=50000
13 Correct 86 ms 15172 KB n=10
14 Correct 75 ms 15172 KB n=685
15 Correct 81 ms 15172 KB n=623
16 Correct 50 ms 15172 KB n=973
17 Correct 61 ms 15172 KB n=989
18 Correct 24 ms 15172 KB n=563
19 Correct 23 ms 15172 KB n=592
20 Correct 26 ms 15172 KB n=938
21 Correct 25 ms 15172 KB n=747
22 Correct 25 ms 15172 KB n=991
23 Runtime error 67 ms 32400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Halted 0 ms 0 KB -