답안 #157711

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157711 2019-10-12T18:15:31 Z a_player Job Scheduling (CEOI12_jobs) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int N,M,D;
int s[1000001];
bool check(int T){
  if(T>=M)return true;
  if(T==0)return false;
    for(int i=0;i<M;i++)if(s[i]+D<max(s[i],i/T+1)return false;
     return true;
}
int main(){
  cin>>N>>D>>M;
  for(int i=0;i<M;i++)cin>>s[i];
  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;
  for(int i=0;i<N;i++){
    for(int z=i*(x+1);z<M&&z<(i+1)*(x+1);z++)cout<<z+1<<" ";
    cout<<0<<endl;
  }
}

Compilation message

jobs.cpp: In function 'bool check(int)':
jobs.cpp:10:28: warning: init-statement in selection statements only available with -std=c++1z or -std=gnu++1z
     for(int i=0;i<M;i++)if(s[i]+D<max(s[i],i/T+1)return false;
                            ^
jobs.cpp:10:50: error: expected ';' before 'return'
     for(int i=0;i<M;i++)if(s[i]+D<max(s[i],i/T+1)return false;
                                                  ^~~~~~
jobs.cpp:10:34: warning: value computed is not used [-Wunused-value]
     for(int i=0;i<M;i++)if(s[i]+D<max(s[i],i/T+1)return false;
                            ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:11:6: error: expected primary-expression before 'return'
      return true;
      ^~~~~~
jobs.cpp:11:6: error: expected ')' before 'return'
jobs.cpp:12:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^