# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
378646 | daniel920712 | Gift (IZhO18_nicegift) | C++14 | 2067 ms | 140416 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
#include <map>
#include <vector>
using namespace std;
map < int , stack < int > > all;
vector < pair < int , int > > que;
int tt[1000005];
int main()
{
//freopen("aa.txt","w+t",stdout);
int N,K,i,j,ans=0,x,y,a,b,t;
scanf("%d %d",&N,&K);
for(i=1;i<=N;i++)
{
scanf("%d",&t);
all[t].push(i);
ans+=t;
tt[i]=t;
}
if(ans%K) printf("-1\n");
else
{
while(!all.empty())
{
x=all.begin()->second.top();
a=all.begin()->first;
all[a].pop();
if(prev(all.end())->second.empty())
{
printf("-1\n");
return 0;
}
y=prev(all.end())->second.top();
b=prev(all.end())->first;
all[b].pop();
//printf("1 %d %d\n",x,y);
que.push_back(make_pair(x,y));
if(all[a].empty()) all.erase(a);
if(a!=b&&all[b].empty()) all.erase(b);
if(a!=1) all[a-1].push(x);
if(b!=1) all[b-1].push(y);
}
printf("%d\n",ans/K);
for(auto i:que) printf("1 %d %d\n",i.first,i.second);
}
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... |