Submission #950043

# Submission time Handle Problem Language Result Execution time Memory
950043 2024-03-20T04:03:17 Z Abito Cookies (JOI23_cookies) C++17
7 / 100
5 ms 1504 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=15005;
int b[N],n,m,a[N],s,k;
vector<int> v[N];
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i],s+=a[i];
    cin>>m;
    for (int i=1;i<=m;i++) cin>>b[i];
    if (s%b[1]){
        cout<<-1<<endl;
        return 0;
    }
    k=s/b[1];
    priority_queue<pair<int,int>> pq;
    for (int i=1;i<=k;i++) pq.push({0,i});
    for (int i=1;i<=n;i++){
        while (a[i]--){
            pair<int,int> x=pq.top();pq.pop();
            v[x.S].pb(i);
            x.F--;
            pq.push(x);
        }
    }bool ok=true;
    for (int i=1;i<=k;i++){
        ok&=(v[i].size()==b[1]);
        sort(v[i].begin(),v[i].end());
        for (int j=0;j<(int)v[i].size()-1;j++) ok&=(v[i][j]!=v[i][j+1]);
    }
    if (!ok){
        cout<<-1<<endl;
        return 0;
    }
    cout<<k<<endl;
    for (int i=1;i<=k;i++){
        cout<<v[i].size()<<' ';
        for (auto u:v[i]) cout<<u<<' ';
        cout<<endl;
    }
    return 0;
}

Compilation message

cookies.cpp: In function 'int32_t main()':
cookies.cpp:40:25: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   40 |         ok&=(v[i].size()==b[1]);
      |              ~~~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 5 ms 1504 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 604 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 3 ms 1112 KB Output is correct
19 Correct 4 ms 1116 KB Output is correct
20 Correct 3 ms 908 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 2 ms 860 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -