답안 #918277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918277 2024-01-29T14:16:09 Z Aiperiii Job Scheduling (CEOI12_jobs) C++14
100 / 100
291 ms 16680 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
signed main(){
   ios_base::sync_with_stdio();
   cin.tie(0);cout.tie(0);
   int n,m,d;
   cin>>n>>d>>m;
   vector <pair <int,int> > v;
   for(int i=0;i<m;i++){
      int x;cin>>x;
      v.pb({x,i+1});
   }
   sort(all(v));
   //for(auto x : v)cout<<x.ff<<" "<<x.ss<<"\n";
   int l=0,r=1e6+5;
   while(l+1<r){
      int md=(l+r)/2;
      int p=0;
      for(int i=1;i<=n;i++){
         int cnt=md;
         while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
            cnt--;
            p++;
         }
         //cout<<p<<"\n";
      }
      //cout<<md<<" "<<p<<"\n";
      if(p==v.size())r=md;
      else l=md;
   }
   cout<<r<<"\n";
   int p=0;
   for(int i=1;i<=n;i++){
      int cnt=r;
      while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
         cnt--;
         cout<<v[p].ss<<" ";
         p++;
      }
      cout<<0<<"\n";
   }
}
/*
8 2 12
1 2 3 4 5 6 7 8 9 10 11 12
1 2 4 2 1 3 5 6 2 3  6  4
1 3 5 2 1 4 5 6 2 3  6  4
 */

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:25:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |          while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
      |                         ~^~~~~~~~~
jobs.cpp:32:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |       if(p==v.size())r=md;
      |          ~^~~~~~~~~~
jobs.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       while(cnt>0 && p<v.size() && v[p].ff<=i && v[p].ff>=i-d){
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 2256 KB Output is correct
2 Correct 26 ms 2172 KB Output is correct
3 Correct 29 ms 2256 KB Output is correct
4 Correct 26 ms 2256 KB Output is correct
5 Correct 36 ms 1992 KB Output is correct
6 Correct 23 ms 2020 KB Output is correct
7 Correct 23 ms 2168 KB Output is correct
8 Correct 23 ms 2236 KB Output is correct
9 Correct 35 ms 2172 KB Output is correct
10 Correct 38 ms 2360 KB Output is correct
11 Correct 30 ms 2084 KB Output is correct
12 Correct 79 ms 3768 KB Output is correct
13 Correct 116 ms 5536 KB Output is correct
14 Correct 138 ms 7932 KB Output is correct
15 Correct 150 ms 9076 KB Output is correct
16 Correct 249 ms 11860 KB Output is correct
17 Correct 274 ms 13032 KB Output is correct
18 Correct 249 ms 15792 KB Output is correct
19 Correct 291 ms 16680 KB Output is correct
20 Correct 240 ms 13784 KB Output is correct