답안 #505134

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
505134 2022-01-10T16:58:02 Z abc864197532 Gift (IZhO18_nicegift) C++17
30 / 100
27 ms 12552 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T a, U ...b) {
    cout << a << ' ', abc(b...);
}
template <typename T> void printv(T l, T r) {
    for (; l != r; ++l) cout << *l << " \n"[l + 1 == r];
}
template <typename A, typename B> istream& operator >> (istream& o, pair<A, B> &a) {
    return o >> a.X >> a.Y;
}
template <typename A, typename B> ostream& operator << (ostream& o, pair<A, B> a) {
    return o << '(' << a.X << ", " << a.Y << ')';
}
template <typename T> ostream& operator << (ostream& o, vector<T> a) {
    bool is = false;
    if (a.empty()) return o << "{}";
    for (T i : a) {o << (is ? ' ' : '{'), is = true, o << i;}
    return o << '}';
}
template <typename T> struct vv : vector <vector <T>> {
    vv(int n, int m, T v) : vector <vector <T>> (n, vector <T>(m, v)) {}
    vv() {}
};
template <typename T> struct vvv : vector <vv <T>> {
    vvv(int n, int m, int k, T v) : vector <vv <T>> (n, vv <T>(m, k, v)) {}
    vvv() {}
};
#ifdef Doludu
#define test(args...) abc("[" + string(#args) + "]", args)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout); 
#else
#define test(args...) void(0)
#define owo ios::sync_with_stdio(false); cin.tie(0)
#endif
const int mod = 1e9 + 7, N = 200000, logN = 20, K = 48763;

int main () {
    owo;
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    vector <lli> pre = {0};
    for (int i = 0; i < n; ++i)
        cin >> a[i], pre.pb(pre.back() + a[i]);
    if (pre.back() % k) {
        cout << -1 << endl;
        return 0;
    }
    lli len = pre.back() / k;
    for (int i : a)
        if (len < i) {
            cout << -1 << endl;
            return 0;
        }
    vector <lli> split;
    for (lli &i : pre)
        i %= len, split.pb(i);
    sort(all(split));
    split.resize(unique(all(split)) - split.begin());
    split.pb(len);
    int m = split.size();
    vector <vector <int>> ans(m);
    for (int i = 0; i < n; ++i) {
        int from = lower_bound(all(split), pre[i]) - split.begin();
        int to = lower_bound(all(split), pre[i + 1]) - split.begin();
        for (int j = (from + 1) % m; ; j = (j + 1) % m) {
            ans[j].pb(i + 1);
            if (j == to)
                break;
        }
    }
    cout << m - 1 << endl;
    for (int i = 1; i < m; ++i) {
        cout << split[i] - split[i - 1] << ' ';
        printv(all(ans[i]));
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 308 KB n=3
4 Correct 0 ms 312 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 316 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 308 KB n=3
4 Correct 0 ms 312 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 316 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 204 KB n=8
9 Correct 1 ms 204 KB n=14
10 Correct 0 ms 204 KB n=11
11 Correct 27 ms 4212 KB n=50000
12 Correct 27 ms 4092 KB n=50000
13 Correct 0 ms 204 KB n=10
14 Correct 1 ms 332 KB n=685
15 Correct 1 ms 332 KB n=623
16 Correct 1 ms 332 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 308 KB n=3
4 Correct 0 ms 312 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 316 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 204 KB n=8
9 Correct 1 ms 204 KB n=14
10 Correct 0 ms 204 KB n=11
11 Correct 27 ms 4212 KB n=50000
12 Correct 27 ms 4092 KB n=50000
13 Correct 0 ms 204 KB n=10
14 Correct 1 ms 332 KB n=685
15 Correct 1 ms 332 KB n=623
16 Correct 1 ms 332 KB n=973
17 Correct 1 ms 332 KB n=989
18 Correct 1 ms 332 KB n=563
19 Correct 2 ms 460 KB n=592
20 Correct 2 ms 460 KB n=938
21 Correct 1 ms 332 KB n=747
22 Correct 2 ms 460 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 12552 KB Jury has the answer but participant has not
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 308 KB n=3
4 Correct 0 ms 312 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 316 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 1 ms 204 KB n=8
9 Correct 1 ms 204 KB n=14
10 Correct 0 ms 204 KB n=11
11 Correct 27 ms 4212 KB n=50000
12 Correct 27 ms 4092 KB n=50000
13 Correct 0 ms 204 KB n=10
14 Correct 1 ms 332 KB n=685
15 Correct 1 ms 332 KB n=623
16 Correct 1 ms 332 KB n=973
17 Correct 1 ms 332 KB n=989
18 Correct 1 ms 332 KB n=563
19 Correct 2 ms 460 KB n=592
20 Correct 2 ms 460 KB n=938
21 Correct 1 ms 332 KB n=747
22 Correct 2 ms 460 KB n=991
23 Incorrect 21 ms 12552 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -