# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516219 | fcmalkcin | Gift (IZhO18_nicegift) | C++17 | 735 ms | 113044 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops, no-stack-protector")
#pragma GCC target("avx,avx2,fma")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define F(i,a,b) for (ll i=a;i<=b;i++)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=1e6+40;
const ll mod=1000003 ;
const ll base=3e18;
/// you will be the best but now you just are trash
/// goal 2/7
ll a[maxn];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("t.inp", "r"))
{
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, k;
cin>> n>> k;
set<pll> st;
for (int i=1;i<=n;i++)
{
cin>> a[i];
st.insert(make_pair(a[i],i));
}
vector<pair<ll,vector<ll>>> ans;
while (st.size()>=k)
{
auto it=(st.begin());
ll val=(*it).ff;
vector<ll> vt;
vt.pb((*it).ss);
it=st.end();
ll len=k-1;
vector<pll> vt1;
while (len--)
{
it--;
vt.pb((*it).ss);
vt1.pb((*it));
}
ans.pb(make_pair(val,vt));
st.erase(st.begin());
for (auto to:vt1)
{
pll p=to;
st.erase(p);
if (p.ff>val)
{
p.ff-=val;
st.insert(p);
}
}
}
if (st.size())
{
cout <<-1;
return 0;
}
cout <<ans.size()<<endl;
for (auto p:ans)
{
cout <<p.ff<<" ";
for (auto to:p.ss) cout <<to<<" ";
cout <<endl;
}
}
컴파일 시 표준 에러 (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... |