답안 #157716

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157716 2019-10-12T18:33:53 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];
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].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;
  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].s);
    }
    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 'bool check(int)':
jobs.cpp:14:20: error: request for member 'f' in 's[i]', which is of non-class type 'int'
       j=max(j,s[i].f);
                    ^
jobs.cpp:15:15: error: request for member 'f' in 's[i]', which is of non-class type 'int'
       if(s[i].f+D<j)return false;
               ^
jobs.cpp: In function 'int main()':
jobs.cpp:22:15: error: request for member 'f' in 's[i]', which is of non-class type 'int'
     cin>>s[i].f;
               ^
jobs.cpp:23:10: error: request for member 's' in 's[i]', which is of non-class type 'int'
     s[i].s=i;
          ^
jobs.cpp:35:20: error: request for member 'f' in 's[i]', which is of non-class type 'int'
       j=max(j,s[i].f);
                    ^
jobs.cpp:36:15: error: request for member 'f' in 's[i]', which is of non-class type 'int'
       if(s[i].f+D<j)st[j].push_back(s[i].s);
               ^
jobs.cpp:36:42: error: request for member 's' in 's[i]', which is of non-class type 'int'
       if(s[i].f+D<j)st[j].push_back(s[i].s);
                                          ^
jobs.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int z=0;z<st[i].size();z++)cout<<st[i][z]<<" ";
                 ~^~~~~~~~~~~~~