답안 #909533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
909533 2024-01-17T08:47:50 Z LucaIlie Cookies (JOI23_cookies) C++17
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

struct cookieType {
    int count, type;
};

const int MAX_N = 15000;
const int MAX_M = 15000;

cookieType cookies[MAX_N];
int boxsize[MAX_M];
vector<int> cookiesByBox[MAX_N];

int main() {
    int n, m;

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> cookies[i].count;
        cookies[i].type = i + 1;
    }
    cin >> m;
    for ( int i = 0; i < m; i++ )
        cin >> boxsize[i];

    int sumCookies = 0, maxCookies = 0;
    for ( int i = 0; i < n; i++ ) {
        sumCookies += cookies[i].count;
        maxCookies = max( maxCookies, cookies[i].count );
    }

    int bs = boxsize[0];
    if ( sumCookies % bs != 0 || maxCookies > sumCookies / bs ) {
        cout << -1;
        return 0;
    }

    sort( cookies, cookies + n, []( cookieType x, cookieType y ) {
        return x.count > y.count;
    } );

    int b = sumCookies / bs, j = 0;
    for ( int i = 0; i < n; i++ ) {
        while ( cookies[i].count > 0 ) {
            cookiesByBox[j].push_back( cookies[i].type );
            j = (j + 1) % b;
            cookies[i].count--;
        }
    }

    cout << b << "\n";
    for ( int i = 0; i < b; i++ ) {
        for ( int j: cookiesByBox[i] )
            cout << j << " ";
        cout << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Too many cookies..
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Incorrect 1 ms 600 KB Unexpected end of file - int32 expected
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Too many cookies..
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Too many cookies..
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Too many cookies..
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Too many cookies..
2 Halted 0 ms 0 KB -