# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90928 | 2018-12-25T08:43:20 Z | toloraia | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 75648 KB |
#include <bits/stdc++.h> #define ll long long #define pb push_back #define F first #define S second using namespace std; const ll N = 5e5 + 5, INF = 1e9 + 5; ll n, k; pair < ll, ll > P[N]; ll nn; vector < ll > V[N], v; ll S; main() { ios::sync_with_stdio(false); cin>>n>>k; for (ll i = 1; i <= n; i++){ cin>>P[i].F; P[i].S = i; S += P[i].F; } sort (P + 1, P + n + 1); reverse (P + 1, P + n + 1); /*if (S <= 1e5){ while (P[k].F > 0){ ll I1 = k, I2 = k; for (ll i = 20; i >= 0; i--){ if (I1 - (1<<i) <= 0) continue; if (P[I1 - (1<<i)].F == P[k].F) I1 -= (1<<i); } for (ll i = 20; i >= 0; i--){ if (I2 + (1<<i) > n) continue; if (P[I2 + (1<<i)].F == P[k].F) I2 += (1<<i); } v.clear(); for (ll i = 1; i < I1; i++){ v.pb (P[i].S); P[i].F--; } for (ll i = I2; (ll)v.size() < k; i--){ v.pb (P[i].S); P[i].F--; } V[++nn] = v; } if (P[1].F > 0){ cout<<-1<<endl; return 0; } cout<<nn<<endl; for (ll i = 1; i <= nn; i++){ cout<<"1 "; for (ll j = 0; j < k; j++) cout<<V[i][j]<<" "; cout<<endl; } return 0; }*/ if (P[1].F == P[n].F){ ll m = __gcd (P[1].F, m); ll d = k / m; if (n % d != 0){ cout<<-1<<endl; return 0; } ll p = P[1].F / m; /*if (n * m > 3e6){ assert(0); return 0; }*/ cout<<n / d<<endl; for (ll i = 1; i <= n; i += d){ cout<<p<<" "; for (ll j = i; j < i + k; j++) cout<<(j - 1) % n + 1<<" "; cout<<endl; } return 0; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12152 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12152 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12152 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2048 ms | 75648 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12152 KB | Unexpected end of file - int32 expected |
2 | Halted | 0 ms | 0 KB | - |