# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
92789 | Vardanyan | Gift (IZhO18_nicegift) | C++14 | 1348 ms | 120272 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const long long N = 1000*1000+5;
pair<long long,long long> a[N];
int main() {
long long n,k;
scanf("%lld%lld",&n,&k);
long long sum = 0;
long long mns = 1;
set<pair<long long,long long >,greater<pair<long long,long long> > > ms;
for(long long i = 1;i<=n;i++){
scanf("%lld",&a[i].first);
a[i].second = i;
sum+=a[i].first;
ms.insert(a[i]);
}
sort(a+1,a+1+n);
if(sum>1000*100){
long long x = k/__gcd(n,k);
if(a[n].first%x){
printf("-1\n");
return 0;
}
mns = a[n].first/x;
}
vector<vector<long long> > ans;
while(1){
long long kk = k;
vector<long long> now;
set<pair<long long,long long> >::iterator it = ms.begin();
vector<pair<long long,long long> > add;
for(;it!=ms.end();it++){
pair<long long,long long> x = *it;
if(x.first-mns<0){
printf("-1\n");
return 0;
}
//x.first--;
sum-=mns;
now.push_back(x.second);
kk--;
add.push_back(x);
if(kk == 0) break;
}
for(long long i = 0;i<add.size();i++){
ms.erase(ms.find(add[i]));
add[i].first-=mns;
ms.insert(add[i]);
}
ans.push_back(now);
if(sum == 0) break;
}
printf("%lld\n",ans.size());
for(long long i = 0;i<ans.size();i++){
printf("%lld ",mns);
for(long long j = 0;j<ans[i].size();j++){
printf("%lld ",ans[i][j]);
}
printf("\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... |