# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1114644 | 2024-11-19T10:02:48 Z | adiyer | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 249852 KB |
#include <bits/stdc++.h> #define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); #define all(x) (x.begin(), x.end()) #define pb push_back // #define int long long typedef long long ll; using namespace std; const int N = 1e6 + 11; const int mod = 1e9 + 7; const ll inf = 1e18 + 11; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); ll n, k; ll a[N]; set < pair < ll, ll >, greater < pair < ll, ll > > > st; vector < vector < ll > > ans; void solve(){ cin >> n >> k; for(ll i = 1; i <= n; i++) cin >> a[i], st.insert({a[i], i}); while(st.size() >= k){ vector < ll > pos = {1}; vector < pair < ll, ll > > del; for(auto it : st){ del.pb(it); pos.pb(it.second); if(del.size() == k) break; } for(auto it : del) st.erase(it); for(auto it : del) st.insert({it.first - 1, it.second}); while(st.size() && (st.begin() -> first) == 0) st.erase(st.begin()); ans.pb(pos); } if(st.empty()){ cout << ans.size() << '\n'; for(auto it : ans){ for(ll x : it) cout << x << ' '; cout << '\n'; } } } const bool Cases = 0; signed main(){ adiyer(); int CS = 1; if(Cases) cin >> CS; while(CS--) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Incorrect | 1 ms | 336 KB | Unexpected end of file - int32 expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Incorrect | 1 ms | 336 KB | Unexpected end of file - int32 expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Incorrect | 1 ms | 336 KB | Unexpected end of file - int32 expected |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2058 ms | 249852 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | n=4 |
2 | Correct | 1 ms | 336 KB | n=3 |
3 | Incorrect | 1 ms | 336 KB | Unexpected end of file - int32 expected |
4 | Halted | 0 ms | 0 KB | - |