답안 #1117233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117233 2024-11-23T04:54:10 Z Alan1234 Job Scheduling (CEOI12_jobs) C++14
0 / 100
100 ms 13896 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vii vector<vector<int>>
#define vi vector<int>



// void setIO(string name = "") {
// 	cin.tie(0)->sync_with_stdio(0);
// 	if (name.size()) {
// 		freopen((name + ".in").c_str(), "r", stdin);
// 		freopen((name + ".out").c_str(), "w", stdout);
// 	}
// }
int n,d,m;
vector<vector<int>> days; 

bool check(int x)
{
    int jobs_remain[100005], index = 1;
    for (int i = 1; i <= n; i++)
    {   
        if(i > index + d)  return false;
        jobs_remain[i] = days[i].size();
        jobs_remain[index] -= x;
        if(jobs_remain[index] <= 0) index++;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> d >> m;
    days.resize(n);
    int num;
    for (int i = 1; i <= m; i++)
    {   
        cin >> num;
        days[num].emplace_back(i);
    }
    

    int l = 0, r = m + 5,mid;
    while(l < r)
    {
        mid = l + (r - l) / 2;
        if(check(mid))
            r = mid;
        else
            l = mid + 1;
    }
    cout << r << '\n';
    int index,temp;
    for (int i = 1; i <= n; i++)
    {   
        index = 0;
        while(index < days[i].size())
        {
            temp = 1;
            while(temp <= r && index < days[i].size())
            {   
                
                cout << days[i][index] << ' ';
                index++,temp++;
                if(temp <= r && index == days[i].size() && i < n)
                {
                    i++;
                    index = 0;
                }
            }
            cout << 0 << '\n';
        }
        if(!index) cout << 0 << '\n';
    }
    
    return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         while(index < days[i].size())
      |               ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:65:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             while(temp <= r && index < days[i].size())
      |                                ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:70:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                 if(temp <= r && index == days[i].size() && i < n)
      |                                 ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 2000 KB Extra information in the output file
2 Incorrect 11 ms 2000 KB Extra information in the output file
3 Incorrect 11 ms 2000 KB Extra information in the output file
4 Incorrect 12 ms 2000 KB Extra information in the output file
5 Incorrect 11 ms 2164 KB Extra information in the output file
6 Incorrect 12 ms 2000 KB Extra information in the output file
7 Incorrect 11 ms 2000 KB Extra information in the output file
8 Incorrect 15 ms 2000 KB Extra information in the output file
9 Incorrect 17 ms 4596 KB Output isn't correct
10 Incorrect 23 ms 4440 KB Output isn't correct
11 Runtime error 15 ms 3152 KB Execution killed with signal 11
12 Runtime error 33 ms 4680 KB Execution killed with signal 11
13 Runtime error 37 ms 7892 KB Execution killed with signal 11
14 Incorrect 51 ms 6324 KB Output isn't correct
15 Runtime error 58 ms 10824 KB Execution killed with signal 11
16 Incorrect 77 ms 9032 KB Output isn't correct
17 Incorrect 100 ms 10824 KB Output isn't correct
18 Incorrect 89 ms 11164 KB Output isn't correct
19 Incorrect 98 ms 13896 KB Output isn't correct
20 Incorrect 87 ms 10832 KB Output isn't correct