QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#597001 | #6339. Cookies | Mispertion# | 0 | 0ms | 3876kb | C++23 | 2.3kb | 2024-09-28 16:51:21 | 2024-09-28 16:51:22 |
answer
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"
const ld PI = 3.1415926535;
const int N = 1e3+5;
const int M = 50 + 1;
const int mod = 1e9+7;
const int infi = 1e15;
const ll infl = LLONG_MAX;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
int n, a[N], m, b[N], dp[N];
void solve(){
cin >> n;
int sm = 0, mx = -1;
for(int i = 1; i <= n; i++){
cin >> a[i];
sm += a[i];
mx = max(mx, a[i]);
}
cin >> m;
for(int i = 1; i <= m; i++)
cin >> b[i];
if(sm % b[1] != 0){
cout << -1 << '\n';
return;
}
if((sm / b[1]) < mx){
cout << -1 << '\n';
return;
}
set<pii> st;
for(int i = 1; i <= n; i++){
st.insert({a[i], i});
}
vector<vector<int>> ans = {};
while(sz(st) > 0){
auto it = st.rbegin();
vector<int> da = {};
vector<pii> td = {};
for(int i = 0; i < b[1]; i++, it++){
da.pb(it->S);
td.pb(*it);
}
for(auto e : td){
st.erase(e);
if(e.F != 1)
st.insert({e.F - 1, e.S});
}
}
cout << sz(ans) << '\n';
for(auto e : ans){
cout << sz(e) << ' ';
for(auto e1 : e){
cout << e1 << ' ';
}
cout << '\n';
}
}
signed main() {
mispertion;
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3580kb
input:
1 1 1 1
output:
0
result:
wrong answer there are unused item 1
Subtask #2:
score: 0
Wrong Answer
Test #28:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
1 15 1 1
output:
0
result:
wrong answer there are unused item 1
Subtask #3:
score: 0
Wrong Answer
Test #45:
score: 0
Wrong Answer
time: 0ms
memory: 3700kb
input:
2 7 8 2 1 2
output:
0
result:
wrong answer there are unused item 1
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%