답안 #1085620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085620 2024-09-08T13:40:22 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
92 / 100
285 ms 28188 KB
#include <bits/stdc++.h>

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

bool moze(long long k)
{
    long long rabota = 0;
    for (long long i=1;i<=n;i++)
    {
        rabota += freq[i];
        long long potrebni_denovi = rabota/k;
        if (rabota%k>0) potrebni_denovi++;
        if (potrebni_denovi>d+1) return false;
        rabota-=k;
        if (rabota<0) rabota = 0;
    }
    if (rabota<=0) return true;
}

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

void pecati(long long k)
{
    vector<pair<long long,long long> > q;
    for (long long i=0;i<v.size();i++) q.push_back({v[i],i+1});
    sort(q.begin(),q.end());
    long long den=1,koristeni=0;
    for (long long i=0;i<q.size();i++)
    {
        if (koristeni==k)
        {
            koristeni=0;
            den++;
            cout<<0<<endl;
        }
        long long 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 (long long i=0;i<m;i++)
    {
        long long a;
        cin>>a;
        freq[a]++;
        v.push_back(a);
    }

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

Compilation message

jobs.cpp: In function 'void pecati(long long int)':
jobs.cpp:34:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (long long i=0;i<v.size();i++) q.push_back({v[i],i+1});
      |                        ~^~~~~~~~~
jobs.cpp:37:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (long long i=0;i<q.size();i++)
      |                        ~^~~~~~~~~
jobs.cpp: In function 'bool moze(long long int)':
jobs.cpp:21:1: warning: control reaches end of non-void function [-Wreturn-type]
   21 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 3420 KB Output is correct
2 Correct 23 ms 3416 KB Output is correct
3 Correct 23 ms 3484 KB Output is correct
4 Correct 23 ms 3420 KB Output is correct
5 Correct 24 ms 3420 KB Output is correct
6 Correct 23 ms 3416 KB Output is correct
7 Correct 27 ms 3424 KB Output is correct
8 Correct 29 ms 3416 KB Output is correct
9 Correct 119 ms 3660 KB Output is correct
10 Correct 119 ms 3660 KB Output is correct
11 Correct 21 ms 3416 KB Output is correct
12 Correct 40 ms 6996 KB Output is correct
13 Correct 68 ms 11604 KB Output is correct
14 Correct 95 ms 13880 KB Output is correct
15 Incorrect 103 ms 15684 KB Extra information in the output file
16 Correct 140 ms 21768 KB Output is correct
17 Correct 154 ms 22816 KB Output is correct
18 Correct 172 ms 24864 KB Output is correct
19 Partially correct 285 ms 28188 KB Partially correct
20 Correct 155 ms 22888 KB Output is correct