답안 #767673

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767673 2023-06-27T03:32:17 Z Trunkty Gift (IZhO18_nicegift) C++14
30 / 100
196 ms 47160 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll

int n,k,tot;
int arr[1000005];
set<pair<int,int>> s;
vector<vector<int>> ans;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        s.insert({arr[i],i});
        tot += arr[i];
    }
    if(tot%k!=0 or tot/k<(*prev(s.end())).first){
        cout << -1 << "\n";
        return 0;
    }
    int lef=tot/k;
    s.insert({0,0});
    while((*prev(s.end())).first>0){
        vector<pair<int,int>> v;
        auto it = s.end();
        for(int i=1;i<=k;i++){
            it--;
            v.push_back((*it));
        }
        for(pair<int,int> i:v){
            s.erase(i);
        }
        int torem = min(v.back().first,lef-(*prev(s.end())).first);
        lef -= torem;
        vector<int> ps={torem};
        for(pair<int,int> i:v){
            ps.push_back(i.second);
            s.insert({i.first-torem,i.second});
        }
        ans.push_back(ps);
    }
    cout << ans.size() << "\n";
    for(vector<int> i:ans){
        for(int j:i){
            cout << j << " ";
        }
        cout << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 0 ms 212 KB n=14
10 Correct 0 ms 212 KB n=11
11 Correct 35 ms 5132 KB n=50000
12 Correct 26 ms 4540 KB n=50000
13 Correct 0 ms 212 KB n=10
14 Correct 1 ms 340 KB n=685
15 Correct 1 ms 340 KB n=623
16 Correct 1 ms 340 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 0 ms 212 KB n=14
10 Correct 0 ms 212 KB n=11
11 Correct 35 ms 5132 KB n=50000
12 Correct 26 ms 4540 KB n=50000
13 Correct 0 ms 212 KB n=10
14 Correct 1 ms 340 KB n=685
15 Correct 1 ms 340 KB n=623
16 Correct 1 ms 340 KB n=973
17 Correct 2 ms 340 KB n=989
18 Correct 1 ms 340 KB n=563
19 Correct 1 ms 340 KB n=592
20 Correct 1 ms 340 KB n=938
21 Correct 1 ms 340 KB n=747
22 Correct 1 ms 340 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Incorrect 196 ms 47160 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB n=4
2 Correct 0 ms 212 KB n=3
3 Correct 0 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 212 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 0 ms 212 KB n=5
8 Correct 0 ms 212 KB n=8
9 Correct 0 ms 212 KB n=14
10 Correct 0 ms 212 KB n=11
11 Correct 35 ms 5132 KB n=50000
12 Correct 26 ms 4540 KB n=50000
13 Correct 0 ms 212 KB n=10
14 Correct 1 ms 340 KB n=685
15 Correct 1 ms 340 KB n=623
16 Correct 1 ms 340 KB n=973
17 Correct 2 ms 340 KB n=989
18 Correct 1 ms 340 KB n=563
19 Correct 1 ms 340 KB n=592
20 Correct 1 ms 340 KB n=938
21 Correct 1 ms 340 KB n=747
22 Correct 1 ms 340 KB n=991
23 Incorrect 196 ms 47160 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -