Submission #338572

# Submission time Handle Problem Language Result Execution time Memory
338572 2020-12-23T12:51:06 Z kutbilim_one Gift (IZhO18_nicegift) C++14
0 / 100
598 ms 70696 KB
/** kutbilim.one **/
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
                          /*
ifstream in("test.txt"); 
#define cin in              */

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k; 
    cin >> n >> k;
    priority_queue< pair<int, int> > q;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    	q.push({a[i], i});
    }

    vector< pair<int, vector<int>> > result;
    while(true){
    	vector<int> val(k, 0), ind(k, 0);
    	for(int i = 0; i < k; i++){
    		val[i] = q.top().first;
    		ind[i] = q.top().second;
    		q.pop();
    	}
       	
       	if(val[0] == 0) break;
    	int x = val.back();
    	if(x == 0) return cout << -1, 0;
    	result.push_back({x, ind});
    	for(int i = k-1; i >= 0; i--){
    		val[i] -= x;
        	q.push({val[i], ind[i]});
    	}
    }

	cout << result.size() << endl;
    for(auto i : result){
    	cout << i.first << " ";
    	for(auto j : i.second) cout << j << " ";
    	cout << endl;
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 598 ms 70696 KB Integer 0 violates the range [1, 1000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Taken too much stones from the heap
2 Halted 0 ms 0 KB -