| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 645680 | mentaldora | Gift (IZhO18_nicegift) | C++14 | 14 ms | 2012 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz size()
#define mk make_pair
#define ff first
#define pll pair<ll, ll>
#define pii pair<int, int>
#define ull unsigned long long
#define ss second
#define all(x) x.begin(), x.end()
#define Resh cin>>tt;while(tt--)solve();
#define yes cout <<"Yes"<<"\n";
#define no cout <<"No"<<"\n";
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define left(v) v + v
#define right(v) v + v + 1
const long double PI = acos(-1);
const long long n6 = 1e6 + 10;
const long long n5 = 1e5+1;
const long long n4 = 1e4 + 10;
const long long inf = 1e9;
const long long mod = 16714589;
const int BL = 60090;
const long long MAXN = 1e5+5;
ll a[n5];
multiset<pll> ms;
vector<vector<pll>> ans;
main() {
fast
ll n, k, cnt=0;
cin >> n >> k;
for(int i = 1;i <= n;i++) {
cin >> a[i];
cnt+=a[i];
}
if(cnt % k) {
cout << -1;
return 0;
}
for(int i = 1;i <= n;i++) {
ms.insert(mk(a[i], i));
}
while(ms.sz >= k) {
vector<pll> v;
while(v.sz < k) {
pll p = *ms.rbegin();
p.ff--;
v.pb(p);
ms.erase(--ms.end());
}
for(auto c : v) {
if(c.ff) {
ms.insert(c);
}
}
ans.pb(v);
}
cout << ans.size() <<'\n';
for(auto c : ans) {
cout << "1 ";
for(auto t : c) {
cout << t.ss << " ";
}
cout <<'\n';
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
