# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89507 | Hideo | Gift (IZhO18_nicegift) | C++14 | 890 ms | 144604 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.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 7;
const int INF = 1e9 + 7;
int a[N], p[N];
int n, k, s;
vector < pair < int, int > > dq[N];
vector < int > ans[N];
main(){
cin >> n >> k;
int mx = -1;
for (int i = 0; i < n; i++){
scanf("%lld", &a[i]);
s += a[i];
mx = max(mx, a[i]);
}
int h = s / k, cs = 0, c = 0;
if (mx > h || s % k != 0){
cout << -1;
return 0;
}
for (int i = 0; i < n; i++){
if(a[i] == 0) continue;
if (cs + a[i] >= h){
a[i] -= (h - cs);
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... |