Submission #140537

# Submission time Handle Problem Language Result Execution time Memory
140537 2019-08-03T12:48:58 Z path Job Scheduling (CEOI12_jobs) C++14
55 / 100
514 ms 17532 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long int ll;
const int N=1e6+3;
int n,d,m;
pair<int,int> a[N];
bool chk(int x){
    queue < pair<int,int> > q;
    pair<int,int> tmp;
    for(int i=0;i<m;i++)
        q.push(make_pair(a[i].f,a[i].f+d));
    for(int i=1;i<=n&&q.size();i++){
        for(int j=0;j<x&&q.size();j++){
            tmp=q.front();
            q.pop();
            if(tmp.s<i) return 0;
        }
    }
    return (!q.size());
}
void out (int x){
    queue <int> q;
    int tmp;
    for(int i=0;i<m;i++)
        q.push(a[i].s);
    for(int i=1;i<=n;i++){
        for(int j=0;j<x&&q.size();j++){
            tmp=q.front();
            q.pop();
            cout<<tmp<<" ";
        }
        cout<<0<<'\n';
    }
    return;
}
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin>>n>>d>>m;
    for(int i=0;i<m;i++){
        cin>>a[i].f;
        a[i].s=i+1;
    }
    sort(a,a+m);
    int s=1,e=m,mid;
    while(s<=e){
        mid=(s+e)/2;
        if(chk(mid))
            e=mid-1;
        else
            s=mid+1;
    }
    e++;
    cout<<e<<'\n';
    out(e);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 2116 KB Output isn't correct
2 Incorrect 40 ms 2240 KB Output isn't correct
3 Incorrect 40 ms 2168 KB Output isn't correct
4 Incorrect 40 ms 2112 KB Output isn't correct
5 Incorrect 40 ms 2232 KB Output isn't correct
6 Incorrect 40 ms 2148 KB Output isn't correct
7 Incorrect 39 ms 2144 KB Output isn't correct
8 Incorrect 39 ms 2172 KB Output isn't correct
9 Correct 55 ms 2396 KB Output is correct
10 Correct 54 ms 2368 KB Output is correct
11 Correct 47 ms 2104 KB Output is correct
12 Correct 102 ms 4000 KB Output is correct
13 Correct 153 ms 6056 KB Output is correct
14 Correct 208 ms 7868 KB Output is correct
15 Incorrect 263 ms 9736 KB Output isn't correct
16 Correct 318 ms 11816 KB Output is correct
17 Correct 386 ms 13556 KB Output is correct
18 Correct 448 ms 15420 KB Output is correct
19 Correct 514 ms 17532 KB Output is correct
20 Correct 395 ms 13532 KB Output is correct