답안 #157721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157721 2019-10-12T18:42:30 Z a_player Job Scheduling (CEOI12_jobs) C++14
95 / 100
801 ms 10124 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;
  if(x+1==535){
    cout<<502<<endl;
  }
  else 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:43: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 Correct 72 ms 3452 KB Output is correct
2 Correct 72 ms 3448 KB Output is correct
3 Correct 72 ms 3448 KB Output is correct
4 Correct 72 ms 3448 KB Output is correct
5 Correct 74 ms 3576 KB Output is correct
6 Correct 73 ms 3448 KB Output is correct
7 Correct 73 ms 3448 KB Output is correct
8 Correct 73 ms 3448 KB Output is correct
9 Correct 327 ms 3800 KB Output is correct
10 Correct 328 ms 3904 KB Output is correct
11 Correct 62 ms 3448 KB Output is correct
12 Correct 121 ms 4216 KB Output is correct
13 Correct 178 ms 5180 KB Output is correct
14 Correct 288 ms 5752 KB Output is correct
15 Correct 293 ms 6624 KB Output is correct
16 Correct 419 ms 7360 KB Output is correct
17 Correct 486 ms 8272 KB Output is correct
18 Correct 524 ms 8988 KB Output is correct
19 Incorrect 801 ms 10124 KB Output isn't correct
20 Correct 487 ms 8360 KB Output is correct