답안 #522268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522268 2022-02-04T11:29:20 Z vonatlus Gift (IZhO18_nicegift) C++17
7 / 100
2000 ms 15948 KB
/// adil sultanov | vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<ll, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;

void ma1n() {
    ll n, k;
    cin >> n >> k;
    vector<pii> a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].x, a[i].y = i;
        sum += a[i].x;
    }
    if (sum%k) {
        cout << -1, exit(0);
    }
    vector<vector<int>> ans;
    while (1) {
        sort(all(a));
        reverse(all(a));
        //for (auto it : a) cout << it.x << " ";
        //cout << "\n";
        if (a[0].x == 0) break;
        for (int i = 1; i < k; ++i) {
            if (a[i].x == 0) {
                cout << -1, exit(0);
            }
        }
        vector<int> v;
        ll d = a[k-1].x-(k < n && a[k].x ? a[k].x : 1ll)+1;
        v.pb(d-1);
        for (int i = 0; i < k; ++i) {
            a[i].x -= d;
            v.pb(a[i].y);
        }
        ans.pb(v);
    }
    cout << sz(ans) << "\n";
    for (auto v : ans) {
        for (int x : v) cout << x+1 << " ";
        cout << "\n";
    }
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 332 KB n=8
9 Correct 5 ms 844 KB n=14
10 Correct 3 ms 588 KB n=11
11 Execution timed out 2071 ms 1236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 332 KB n=8
9 Correct 5 ms 844 KB n=14
10 Correct 3 ms 588 KB n=11
11 Execution timed out 2071 ms 1236 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 15948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 0 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 332 KB n=8
9 Correct 5 ms 844 KB n=14
10 Correct 3 ms 588 KB n=11
11 Execution timed out 2071 ms 1236 KB Time limit exceeded
12 Halted 0 ms 0 KB -