답안 #157719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157719 2019-10-12T18:41:15 Z a_player Job Scheduling (CEOI12_jobs) C++14
54 / 100
912 ms 20344 KB
#include <bits/stdc++.h>
#define f first
#define se second

using namespace std;

int N,M,D;
pair<int,int> s[1000001];
vector<int> st[100001];
bool check(int T){
  if(T>=M)return true;
  if(T==0)return false;
  int j=0;
    for(int i=0;i<M;i++){
      if(i%T==0)j++;
      j=max(j,s[i].f);
      if(s[i].f+D<j)return false;
    }
     return true;
}
int main(){
  cin>>N>>D>>M;
  for(int i=0;i<M;i++){
    cin>>s[i].f;
    s[i].se=i+1;
  }
  sort(s,s+M);
  int x=-1;
  for(int b=M;b>=1;b/=2)
  while(!check(x+b))x+=b;

  cout<<x+1<<endl;
  x++;
  int j=0;
    for(int i=0;i<M;i++){
      if(i%x==0)j++;
      j=max(j,s[i].f);
      if(s[i].f+D>=j)st[j].push_back(s[i].se);
    }
    for(int i=0;i<N;i++){
    for(int z=0;z<st[i].size();z++)cout<<st[i][z]<<" ";
    cout<<0<<endl;
  }
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int z=0;z<st[i].size();z++)cout<<st[i][z]<<" ";
                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 86 ms 4600 KB Partially correct
2 Partially correct 85 ms 4596 KB Partially correct
3 Partially correct 86 ms 4596 KB Partially correct
4 Partially correct 85 ms 4640 KB Partially correct
5 Partially correct 85 ms 4724 KB Partially correct
6 Partially correct 85 ms 4608 KB Partially correct
7 Partially correct 84 ms 4700 KB Partially correct
8 Partially correct 86 ms 4596 KB Partially correct
9 Partially correct 343 ms 4940 KB Partially correct
10 Partially correct 344 ms 4904 KB Partially correct
11 Correct 74 ms 4600 KB Output is correct
12 Partially correct 150 ms 6580 KB Partially correct
13 Correct 220 ms 9044 KB Output is correct
14 Partially correct 341 ms 11344 KB Partially correct
15 Incorrect 356 ms 13816 KB Output isn't correct
16 Correct 493 ms 14072 KB Output is correct
17 Correct 575 ms 18168 KB Output is correct
18 Correct 599 ms 18592 KB Output is correct
19 Incorrect 912 ms 20344 KB Output isn't correct
20 Correct 588 ms 18120 KB Output is correct