제출 #1154145

#제출 시각아이디문제언어결과실행 시간메모리
1154145asdasdGift (IZhO18_nicegift)C++20
0 / 100
680 ms94032 KiB
//gm --- akezhon #include <bits/stdc++.h> // #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define pb push_back #define pf push_front #define F first #define S second #define all(v) v.begin(),v.end() #define pii pair<int,int> #define tm (tl+tr)/2 #define TL v+v, tl, tm #define TR v+v+1, tm+1, tr #define DA l <= tl && tr <= r #define NE r < tl || tr < l #define double long double // #define int long long using namespace std; const int N=2e5+7; const int mod=1e9+7; const int inf=2e9; void AlemAmenov(){ int n, k; cin >> n >> k; int a[n+1]; multiset<pii>st; vector<vector<int>>ans; vector<int>d; for(int i=1; i <= n; i++){ cin >> a[i]; st.insert({a[i], i}); } bool ok=1; while(st.size()){ vector<pii>v; pii x; for(int i=1; i <= k; i++){ if(st.empty()){ ok=0; break; } x=*st.rbegin(); v.pb(x); st.erase(x); } if(!ok)break; vector<int>temp; for(auto [f, i] : v){ if(f-x.F)st.insert({f-x.F, i}); temp.pb(i); } ans.pb(temp); d.pb(x.F); } if(ans.size()*k > 3000000)cout << -1; else { cout << ans.size() << '\n'; for(int i=0; i < ans.size(); i++){ cout << d[i] << ' '; for(int it : ans[i]){ cout << it << ' '; } cout << '\n'; } } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int RealName=1; // cin >> RealNam; // srand(time(0)); while(RealName--) AlemAmenov(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...