제출 #97845

#제출 시각아이디문제언어결과실행 시간메모리
97845RezwanArefin01Job Scheduling (CEOI12_jobs)C++17
40 / 100
289 ms16744 KiB
///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] = {1000010}, a[N]; int 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); vector<int> v; for(int i = 1; i <= m; i++) { scanf("%d", &a[i]); v.push_back(i); } sort(v.begin(), v.end(), [](int i, int j) { return a[i] < a[j]; }); build(1, 1, n); for(int i : v) { update(1, 1, n, query(1, 1, n, a[i], a[i] + d), i); } printf("%d\n", ans); for(int i = 1; i <= n; i++) { for(int x : p[i]) printf("%d ", x); puts("0"); } }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'void build(int, int, int)':
jobs.cpp:16: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:23: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:34:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int m = l + r >> 1; 
             ~~^~~
jobs.cpp: In function 'int main()':
jobs.cpp:41: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:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...