# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516219 | 2022-01-20T16:40:48 Z | fcmalkcin | Gift (IZhO18_nicegift) | C++17 | 735 ms | 113044 KB |
/*#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; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 332 KB | n=3 |
4 | Incorrect | 0 ms | 204 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 332 KB | n=3 |
4 | Incorrect | 0 ms | 204 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 332 KB | n=3 |
4 | Incorrect | 0 ms | 204 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 735 ms | 113044 KB | n=1000000 |
2 | Correct | 453 ms | 71472 KB | n=666666 |
3 | Correct | 239 ms | 37836 KB | n=400000 |
4 | Incorrect | 158 ms | 24320 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | n=4 |
2 | Correct | 0 ms | 204 KB | n=3 |
3 | Correct | 0 ms | 332 KB | n=3 |
4 | Incorrect | 0 ms | 204 KB | Jury has the answer but participant has not |
5 | Halted | 0 ms | 0 KB | - |