답안 #407382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
407382 2021-05-18T20:36:50 Z arayi Gift (IZhO18_nicegift) C++17
30 / 100
2000 ms 352092 KB
//Arayi
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x, ld y1, ld x2, ld y2)
{
    return sqrt((x - x2) * (x - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
    return (a * (a + 1LL)) / 2;
}
mt19937 rnd(363542);
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 0, -1, 0, 1, -1, -1, 1, 1, 0 };
int dy[] = { -1, 0, 1, 0, -1, 1, -1, 1, 0 };


const int N = 5e6 + 30;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const ld e = log2(3);
const int T = 1000;

lli bp(lli a, lli b = mod - 2LL)
{
    lli ret = 1;
    while (b)
    {
        if (b & 1) ret *= a, ret %= mod;
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return ret;
}
ostream& operator<<(ostream& c, pir a)
{
    c << a.fr << " " << a.sc;
    return c;
}
template<class T>
void maxi(T& a, T b)
{
    a = max(a, b);
}
template <class T>
void mini(T& a, T b)
{
    a = min(a, b);
}


int n;
lli a[N], sum, k;
vector<vii> fp;
int main()
{
    fastio;
    cin >> n >> k;
    priority_queue<pair<lli, int> > q;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
        q.push(MP(a[i], i));
    }
    for (int i = 0; i <= (sum - 1LL) / k; i++)
    {
        vii sm;
        for (int j = 0; j < k; j++)
        {
            sm.ad(q.top().sc);
            q.pop();
        }
        for (auto p : sm)
        {
            if (a[p] == 0)
            {
                cout << -1 << endl;
                exit(0);
            }
            a[p]--;
            q.push(MP(a[p], p));
        }
        fp.ad(sm);
    }
    cout << fp.size() << endl;
    for (auto p : fp)
    {
        cout << 1 << " ";
        for (auto p1 : p) cout << p1 + 1 << " ";
        cout << endl;
    }
    return 0;
}


/*

    __
  *(><)*
    \/ /
    ||/
  --||
    ||
    /\
   /  \
  /    \

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n=4
2 Correct 1 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 1 ms 204 KB n=4
6 Correct 1 ms 204 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n=4
2 Correct 1 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 1 ms 204 KB n=4
6 Correct 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 30 ms 1184 KB n=14
10 Correct 18 ms 972 KB n=11
11 Correct 117 ms 4984 KB n=50000
12 Correct 118 ms 5052 KB n=50000
13 Correct 102 ms 3444 KB n=10
14 Correct 93 ms 3052 KB n=685
15 Correct 102 ms 3336 KB n=623
16 Correct 56 ms 1900 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n=4
2 Correct 1 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 1 ms 204 KB n=4
6 Correct 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 30 ms 1184 KB n=14
10 Correct 18 ms 972 KB n=11
11 Correct 117 ms 4984 KB n=50000
12 Correct 118 ms 5052 KB n=50000
13 Correct 102 ms 3444 KB n=10
14 Correct 93 ms 3052 KB n=685
15 Correct 102 ms 3336 KB n=623
16 Correct 56 ms 1900 KB n=973
17 Correct 77 ms 2452 KB n=989
18 Correct 23 ms 960 KB n=563
19 Correct 29 ms 1336 KB n=592
20 Correct 31 ms 1264 KB n=938
21 Correct 27 ms 1096 KB n=747
22 Correct 28 ms 1108 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2102 ms 352092 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB n=4
2 Correct 1 ms 204 KB n=3
3 Correct 1 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 1 ms 204 KB n=4
6 Correct 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 30 ms 1184 KB n=14
10 Correct 18 ms 972 KB n=11
11 Correct 117 ms 4984 KB n=50000
12 Correct 118 ms 5052 KB n=50000
13 Correct 102 ms 3444 KB n=10
14 Correct 93 ms 3052 KB n=685
15 Correct 102 ms 3336 KB n=623
16 Correct 56 ms 1900 KB n=973
17 Correct 77 ms 2452 KB n=989
18 Correct 23 ms 960 KB n=563
19 Correct 29 ms 1336 KB n=592
20 Correct 31 ms 1264 KB n=938
21 Correct 27 ms 1096 KB n=747
22 Correct 28 ms 1108 KB n=991
23 Execution timed out 2102 ms 352092 KB Time limit exceeded
24 Halted 0 ms 0 KB -