답안 #1085615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085615 2024-09-08T13:33:06 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
20 / 100
296 ms 17464 KB
#include <bits/stdc++.h>

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

bool moze(int k)
{
    int rabota = 0;
    for (int i=1;i<=n;i++)
    {
        rabota += freq[i];
        int potrebni_denovi = rabota/k;
        if (rabota%k>0) potrebni_denovi++;
        if (potrebni_denovi>d+1) return false;
        rabota-=k;
    }
    if (rabota<=0) 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:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for (int i=0;i<v.size();i++) q.push_back({v[i],i+1});
      |                  ~^~~~~~~~~
jobs.cpp:36: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]
   36 |     for (int i=0;i<q.size();i++)
      |                  ~^~~~~~~~~
jobs.cpp: In function 'bool moze(int)':
jobs.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 2396 KB Output isn't correct
2 Incorrect 25 ms 2392 KB Output isn't correct
3 Incorrect 23 ms 2140 KB Output isn't correct
4 Incorrect 22 ms 2396 KB Output isn't correct
5 Incorrect 23 ms 2396 KB Output isn't correct
6 Incorrect 24 ms 2396 KB Output isn't correct
7 Incorrect 22 ms 2396 KB Output isn't correct
8 Incorrect 23 ms 2392 KB Output isn't correct
9 Incorrect 127 ms 2396 KB Output isn't correct
10 Incorrect 117 ms 2396 KB Output isn't correct
11 Correct 20 ms 2136 KB Output is correct
12 Correct 40 ms 4240 KB Output is correct
13 Correct 61 ms 6740 KB Output is correct
14 Correct 94 ms 8000 KB Output is correct
15 Incorrect 100 ms 9792 KB Output isn't correct
16 Incorrect 128 ms 13872 KB Output isn't correct
17 Incorrect 161 ms 15108 KB Output isn't correct
18 Incorrect 165 ms 17204 KB Output isn't correct
19 Incorrect 296 ms 17464 KB Output isn't correct
20 Incorrect 157 ms 14552 KB Output isn't correct