답안 #97842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97842 2019-02-18T21:06:39 Z RezwanArefin01 Job Scheduling (CEOI12_jobs) C++17
컴파일 오류
0 ms 0 KB
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 1e5 + 10; 
vector<int> p[N];
int t[N << 2], sz[N] = {1e9}, n, d, m, x, ans; 

void build(int node, int l, int r) {
    t[node] = l;
    if(l == r) return; 
    int m = l + r >> 1; 
    build(node << 1, l, m); 
    build(node << 1 | 1, m + 1, r);
}
int query(int node, int l, int r, int i, int j) {
    if(r < i || l > j) return 0; 
    if(i <= l && r <= j) return t[node]; 
    int m = l + r >> 1;
    int q1 = query(node << 1, l, m, i, j); 
    int q2 = query(node << 1 | 1, m + 1, r, i, j); 
    return sz[q1] <= sz[q2] ? q1 : q2; 
}
void update(int node, int l, int r, int i, int id) {
    if(l == r) {
        ans = max(ans, ++sz[l]);  
        p[l].push_back(id); 
        return; 
    } 
    int m = l + r >> 1; 
    if(i <= m) update(node << 1, l, m, i, id); 
    else update(node << 1 | 1, m + 1, r, i, id); 
    int q1 = t[node << 1], q2 = t[node << 1 | 1];
    t[node] = sz[q1] <= sz[q2] ? q1 : q2; 
}
int main() {
    scanf("%d %d %d", &n, &d, &m); 
    build(1, 1, n); 
    for(int i = 1; i <= m; i++) {
        scanf("%d", &x); 
        update(1, 1, n, query(1, 1, n, x, x + d), i); 
    }
    printf("%d\n", ans); 
    for(int i = 1; i <= n; i++) {
        for(int x : p[i]) printf("%d ", x); 
        puts("0"); 
    }
}

Compilation message

jobs.cpp:10:28: error: narrowing conversion of '1.0e+9' from 'double' to 'int' inside { } [-Wnarrowing]
 int t[N << 2], sz[N] = {1e9}, n, d, m, x, ans; 
                            ^
jobs.cpp: In function 'void build(int, int, int)':
jobs.cpp:15:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m = l + r >> 1; 
             ~~^~~
jobs.cpp: In function 'int query(int, int, int, int, int)':
jobs.cpp:22:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m = l + r >> 1;
             ~~^~~
jobs.cpp: In function 'void update(int, int, int, int, int)':
jobs.cpp:33:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m = l + r >> 1; 
             ~~^~~
jobs.cpp: In function 'int main()':
jobs.cpp:40: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:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x); 
         ~~~~~^~~~~~~~~~