답안 #1085614

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085614 2024-09-08T13:27:28 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
10 / 100
273 ms 17568 KB
#include <bits/stdc++.h>

using namespace std;
int n,d,m;
vector<int> v;
int freq[100001];

bool moze(int k)
{
    int utre=0;
    for (int den=1;den<=n;den++)
    {
        int rabota_denes = freq[den] + utre;
        int potrebno = rabota_denes/k;
        if (rabota_denes%k>0) potrebno++;
        if (potrebno>d) return false;
        utre = rabota_denes-k;
    }
    if (utre>0) return false;

    return true;
}

int bs(int l,int r)
{
    if (l==r) return l;
    int mid = (l+r)/2;
    if (moze(mid)) return bs(l,mid);
    else return bs(mid+1,r);
}

void pecati(int k)
{
    vector<pair<int,int> > q;
    for (int i=0;i<v.size();i++) q.push_back({v[i],i+1});
    sort(q.begin(),q.end());
    int den=1,koristeni=0;
    for (int i=0;i<q.size();i++)
    {
        if (koristeni==k)
        {
            koristeni=0;
            den++;
            cout<<0<<endl;
        }
        int x = q[i].first,it=q[i].second;

        if (den<x)
        {
            while(den<x)
            {
                den++;
                cout<<0<<endl;
            }
        }
        koristeni++;
        cout<<it<<" ";
    }
    while(den<=n)
    {
        cout<<0<<endl;
        den++;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>d>>m;
    for (int i=0;i<m;i++)
    {
        int a;
        cin>>a;
        freq[a]++;
        v.push_back(a);
    }

    int odg = bs(1,m);
    cout<<odg<<endl;
    pecati(odg);
    return 0;
}

Compilation message

jobs.cpp: In function 'void pecati(int)':
jobs.cpp:35:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i=0;i<v.size();i++) q.push_back({v[i],i+1});
      |                  ~^~~~~~~~~
jobs.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i=0;i<q.size();i++)
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 2392 KB Output isn't correct
2 Incorrect 22 ms 2380 KB Output isn't correct
3 Incorrect 22 ms 2136 KB Output isn't correct
4 Incorrect 23 ms 2392 KB Output isn't correct
5 Incorrect 23 ms 2392 KB Output isn't correct
6 Incorrect 27 ms 2140 KB Output isn't correct
7 Incorrect 22 ms 2396 KB Output isn't correct
8 Incorrect 22 ms 2396 KB Output isn't correct
9 Incorrect 117 ms 2384 KB Output isn't correct
10 Incorrect 116 ms 2396 KB Output isn't correct
11 Correct 20 ms 2140 KB Output is correct
12 Incorrect 45 ms 4176 KB Output isn't correct
13 Correct 58 ms 7416 KB Output is correct
14 Incorrect 92 ms 8736 KB Output isn't correct
15 Incorrect 99 ms 9792 KB Output isn't correct
16 Incorrect 137 ms 11668 KB Output isn't correct
17 Incorrect 158 ms 13664 KB Output isn't correct
18 Incorrect 191 ms 16284 KB Output isn't correct
19 Incorrect 273 ms 17568 KB Output isn't correct
20 Incorrect 150 ms 13480 KB Output isn't correct