# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
850294 | srivatsav_kannan | Job Scheduling (CEOI12_jobs) | C++17 | 210 ms | 34920 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <bitset>
#include <climits>
#include <valarray>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <complex>
//#include <bits/stdc++.h>
#define int long long int
#define double long double
#define endl '\n'
#define mod 1000000007
#define inf 2000000000000000000
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree < int , null_type , less , rb_tree_tag , tree_order_statistics_node_update>
const int mxm = 1000001;
pair<int,int> ar[mxm];
int n,d,m;
bool f(int mid){
int day = 1;
int used = 0;
for (int i = 0; i < m; i++){
if (day > n) return false;
used++;
day = max(day, ar[i].first);
if (day-ar[i].first > d || day > n) return false;
if (used == mid) {
used = 0;
day++;
}
}
return true;
}
void solve(){
cin >> n >> d >> m;
for (int i = 0; i < m; i++) {
cin >> ar[i].first;
ar[i].second = i+1;
}
sort(ar, ar+m);
int l = 1, r = m;
while (l < r) {
int mid = (l+r)/2;
if (f(mid)) r = mid;
else l = mid+1;
}
cout << l << endl;
int mid = l;
int day = 1;
int used = 0;
vector<int> ans[n+1];
vector<int> cur;
for (int i = 0; i < m; i++){
used++;
day = max(day, ar[i].first);
ans[day].push_back(ar[i].second);
if (used == mid) {
used = 0;
day++;
}
}
for (int i = 1; i <= n; i++){
ans[i].push_back(0);
for (int j:ans[i]){
cout << j << " ";
}
cout << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("swap.in", "r", stdin);
// freopen("swap.out", "w", stdout);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |