Submission #954713

# Submission time Handle Problem Language Result Execution time Memory
954713 2024-03-28T12:09:35 Z daviedu Job Scheduling (CEOI12_jobs) C++17
40 / 100
206 ms 17312 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
 
struct P{
    ll x, y;
};
 
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
 
 
 
signed main(){
    fastio;
    int n, d, m;
    cin >> n >> d >> m;
    vector<pair<int, int>> arr (m);
    for (int i=1, x; i<=m; i++){
        cin >> x;
        arr[i-1] = {x, i};
    }
    sort(all(arr));
 
    int l=1, r=m, pcs=1;
    while (l<=r){
        int mid = l + (r-l)/2;
        
        bool f = false;
        int j=0;
        for (int i=0; i<n; i++){
            for (int k=0; k<mid && j<m && i+1>=arr[j].first; k++, j++);
        }

        if (j == m){
            r = mid-1;
            pcs = mid;
        }
        else l = mid+1;
    }

    cout << pcs << '\n';
    int j=0;
    for (int i=0; i<n; i++){
        for (int k=0; k<pcs && j<m && i+1>=arr[j].first; k++, j++){
            cout << arr[j].second << ' ';
        }
        cout << 0 << '\n';
    }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:35:14: warning: unused variable 'f' [-Wunused-variable]
   35 |         bool f = false;
      |              ^
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2140 KB Output isn't correct
2 Incorrect 18 ms 2060 KB Output isn't correct
3 Incorrect 15 ms 2140 KB Output isn't correct
4 Incorrect 15 ms 1912 KB Output isn't correct
5 Incorrect 15 ms 2140 KB Output isn't correct
6 Incorrect 15 ms 2140 KB Output isn't correct
7 Incorrect 15 ms 2080 KB Output isn't correct
8 Incorrect 15 ms 2132 KB Output isn't correct
9 Incorrect 26 ms 2140 KB Output isn't correct
10 Incorrect 29 ms 2116 KB Output isn't correct
11 Correct 20 ms 2132 KB Output is correct
12 Correct 41 ms 3848 KB Output is correct
13 Correct 69 ms 5716 KB Output is correct
14 Correct 87 ms 8016 KB Output is correct
15 Correct 107 ms 9592 KB Output is correct
16 Correct 135 ms 12116 KB Output is correct
17 Correct 158 ms 13880 KB Output is correct
18 Incorrect 170 ms 15096 KB Output isn't correct
19 Incorrect 206 ms 17312 KB Output isn't correct
20 Correct 153 ms 13908 KB Output is correct