답안 #767657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
767657 2023-06-27T02:27:06 Z Trunkty Gift (IZhO18_nicegift) C++14
7 / 100
2000 ms 390176 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;
    }
    while((*prev(s.end())).first>0){
        vector<pair<int,int>> v;
        for(int i=1;i<=k;i++){
            v.push_back(*prev(s.end()));
            s.erase(v.back());
        }
        vector<int> ps={v.back().first};
        for(pair<int,int> i:v){
            ps.push_back(i.second);
            s.insert({i.first-v.back().first,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 1 ms 212 KB n=4
2 Correct 1 ms 212 KB n=3
3 Correct 1 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 328 KB n=4
6 Correct 0 ms 212 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 1 ms 212 KB n=3
3 Correct 1 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 328 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 324 KB n=5
8 Correct 1 ms 212 KB n=8
9 Execution timed out 2073 ms 390176 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 1 ms 212 KB n=3
3 Correct 1 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 328 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 324 KB n=5
8 Correct 1 ms 212 KB n=8
9 Execution timed out 2073 ms 390176 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 899 ms 126284 KB n=1000000
2 Correct 543 ms 79980 KB n=666666
3 Correct 295 ms 44792 KB n=400000
4 Execution timed out 2083 ms 220920 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB n=4
2 Correct 1 ms 212 KB n=3
3 Correct 1 ms 212 KB n=3
4 Correct 0 ms 212 KB n=4
5 Correct 0 ms 328 KB n=4
6 Correct 0 ms 212 KB n=2
7 Correct 1 ms 324 KB n=5
8 Correct 1 ms 212 KB n=8
9 Execution timed out 2073 ms 390176 KB Time limit exceeded
10 Halted 0 ms 0 KB -