| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 367616 | nicolaalexandra | Gift (IZhO18_nicegift) | C++14 | 1442 ms | 101328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define DIM 1000010
using namespace std;
//set <pair<long long,int> > s;
priority_queue <pair<long long,int> > h;
vector <pair<long long,int> > w;
vector <long long> sol[DIM];
long long v[DIM];
int n,k,i,el;
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n>>k;
long long sum = 0;
for (i=1;i<=n;i++){
cin>>v[i];
h.push(make_pair(v[i],i));
sum += v[i];
}
if (sum % k){
cout<<-1;
return 0;
}
long long cnt = sum / k;
while (!h.empty()){
if (h.size() < k){
cout<<-1;
return 0;
}
int pas = 0; long long val = 0, val2 = 0;
w.clear();
for (int i=1;i<=k;i++){
val = h.top().first;
int poz = h.top().second;
h.pop();
w.push_back(make_pair(val,poz));
}
if (!h.empty())
val2 = h.top().first;
val = min (val,cnt - val2);
sol[++el].push_back (val);
cnt -= val;
for (auto it : w){
long long x = it.first; int poz = it.second;
sol[el].push_back(poz);
if (x > val)
h.push(make_pair(x-val,poz));
}
}
cout<<el<<"\n";
for (i=1;i<=el;i++){
for (auto it : sol[i])
cout<<it<<" ";
cout<<"\n";
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
