답안 #950034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950034 2024-03-20T03:48:22 Z Abito Cookies (JOI23_cookies) C++17
0 / 100
1 ms 600 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=505;
int b[N],n,m,s;
pair<int,int> a[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].F,a[i].S=i,s+=a[i].F;
    sort(a+1,a+1+n);
    cin>>m;
    for (int i=1;i<=m;i++) cin>>b[i];
    if (n%b[1] || s%b[1]){
        cout<<-1<<endl;
        return 0;
    }
    bool ok=true;
    vector<vector<int>> ans;
    for (int i=1;i<=n;i++){
        int x=a[i].F-a[i-1].F;
        //cout<<a[i].F<<' ';
        if (!x) continue;
        if (n-i+1<b[1]){
            ok=false;
            break;
        }//cout<<i<<' ';
        while (x>0){
            vector<int> v;
            for (int j=i;j<i+b[1];j++) v.pb(a[j].S);
            ans.pb(v);
            x--;
        }
    }
    if (!ok){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans.size()<<endl;
    for (auto v:ans){
        cout<<v.size()<<' ';
        for (auto u:v) cout<<u<<' ';
        cout<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Number of cookies does not match with A_i
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Number of cookies does not match with A_i
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Number of cookies does not match with A_i
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Number of cookies does not match with A_i
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Number of cookies does not match with A_i
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Number of cookies does not match with A_i
2 Halted 0 ms 0 KB -