# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
343223 |
2021-01-03T14:37:54 Z |
Sprdalo |
Gift (IZhO18_nicegift) |
C++17 |
|
804 ms |
77588 KB |
#include <bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;
void no(){
cout << "-1\n";
exit(0);
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cerr.tie(nullptr);
int n, k;
cin >> n >> k;
set<pi> s;
for (int i = 0; i < n; ++i){
int x;
cin >> x;
s.insert({-x, i});
}
vector<vi> sol;
while(!s.empty()){
int len = s.size();
if (len < k) no();
vp t;
for (int i = 0; i < k; ++i){
pi p = *s.begin();
s.erase(s.begin());
t.push_back({-p.first, p.second});
}
vi r = {t.back().first};
int d = t.back().first;
for (int i = 0; i < k; ++i){
t[i].first -= d;
r.push_back(t[i].second+1);
if (t[i].first>0)
s.insert({-t[i].first, t[i].second});
}
sol.push_back(r);
}
cout << (int)sol.size() << '\n';
for (auto& i : sol){
for (auto& j : i)
cout << j << ' ';
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
804 ms |
77588 KB |
n=1000000 |
2 |
Correct |
484 ms |
50156 KB |
n=666666 |
3 |
Correct |
298 ms |
31324 KB |
n=400000 |
4 |
Incorrect |
147 ms |
18284 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
n=4 |
2 |
Correct |
0 ms |
364 KB |
n=3 |
3 |
Correct |
0 ms |
364 KB |
n=3 |
4 |
Correct |
1 ms |
364 KB |
n=4 |
5 |
Correct |
1 ms |
364 KB |
n=4 |
6 |
Correct |
1 ms |
364 KB |
n=2 |
7 |
Correct |
1 ms |
364 KB |
n=5 |
8 |
Correct |
1 ms |
364 KB |
n=8 |
9 |
Incorrect |
1 ms |
364 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |