답안 #258545

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
258545 2020-08-06T06:08:59 Z Molukhyyeh Job Scheduling (CEOI12_jobs) C++14
43 / 100
323 ms 21948 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 
 
int const N = 200001, M = 1e6+1;
int n, d, m;
pair<int,int> v[M];
vector<int> pr[N];
 
bool ok(int md){
     int av = md, day = 0, cur = 0; 
     for(int i = 0; i<m; ++i){
        cur = day; 
        --av;
        if(!av)av = md, ++day;
        if(cur >= v[i].first+d)return false;
     }
     return true;
} 
 
int main(){
    scanf("%d%d%d", &n, &d, &m);
    for(int i = 0; i<m; ++i){
    	scanf("%d", &v[i].first);
    	v[i].second = i+1;
    }
    sort(v, v+m);
    int l = 1, r = M, md, an = m;
    while(l <= r){
    	 md = l + r >> 1;
    	 if(ok(md))r = md-1, an = md;
    	 else l = md+1;
    }
    printf("%d\n", an);
    int day = 0, av = an, ls = 0;
    for(int i = 0; i<m; ++i){
    	printf("%d ", v[i].second);
    	--av;
    	if(!av)av = md, printf("0\n"), ++day;
    }
    for(int i = 0; i<n-day; ++i)puts("0");
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
       md = l + r >> 1;
            ~~^~~
jobs.cpp:36:27: warning: unused variable 'ls' [-Wunused-variable]
     int day = 0, av = an, ls = 0;
                           ^~
jobs.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &d, &m);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:25:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
      scanf("%d", &v[i].first);
      ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 6904 KB Output isn't correct
2 Incorrect 29 ms 6776 KB Output isn't correct
3 Incorrect 28 ms 6776 KB Output isn't correct
4 Incorrect 29 ms 6740 KB Output isn't correct
5 Incorrect 29 ms 6776 KB Output isn't correct
6 Incorrect 30 ms 6648 KB Output isn't correct
7 Incorrect 27 ms 6776 KB Output isn't correct
8 Incorrect 30 ms 6676 KB Output isn't correct
9 Correct 38 ms 6904 KB Output is correct
10 Partially correct 39 ms 6904 KB Partially correct
11 Correct 37 ms 6776 KB Output is correct
12 Correct 74 ms 8696 KB Output is correct
13 Partially correct 108 ms 10488 KB Partially correct
14 Correct 159 ms 12920 KB Output is correct
15 Incorrect 263 ms 14220 KB Output isn't correct
16 Partially correct 220 ms 16760 KB Partially correct
17 Correct 260 ms 18680 KB Output is correct
18 Partially correct 285 ms 19960 KB Partially correct
19 Correct 323 ms 21948 KB Output is correct
20 Correct 260 ms 18680 KB Output is correct