# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
298543 | Marlov | Job Scheduling (CEOI12_jobs) | C++14 | 191 ms | 20472 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Code by @marlov
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
#define INF 100000
#define maxN 100000
int N,D,M;
vector<int> arr[maxN];
bool solve(int num){
priority_queue< pair<int,int> , vector< pair<int,int> > , greater< pair<int,int> > > pq;
for(int i=0;i<N;i++){
int cc=num;
pq.push(make_pair(i,arr[i].size()));
while(!pq.empty()&&cc>0){
if(pq.top().first<i-D) return false;
if(pq.top().second<=cc){
cc-=pq.top().second;
pq.pop();
}else if(pq.top().second>cc){
pair<int,int> cur=pq.top();pq.pop();
cur.second-=cc;
pq.push(cur);
cc=0;
}
}
}
if(pq.size()>0) return false;
return true;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N>>D>>M;
int num;
for(int i=0;i<M;i++){
cin>>num;
num--;
arr[num].push_back(i);
}
int a=0;
int b=1000000;
while(a<b){
int mid=(a+b)/2;
if(solve(mid)){
b=mid;
}else{
a=mid+1;
}
//cout<<a<<" "<<mid<<" "<<b<<endl;
}
cout<<a<<'\n';
int ca=0;
int ci=0;
int tn=a;
int tg=0;
while(ca<N){
if(ci>=arr[ca].size()){
ca++;
ci=0;
}
while(tn>0&&ci<arr[ca].size()){
cout<<arr[ca][ci]<<" ";
ci++;
tn--;
}
if(tn==0){
tg++;
cout<<0<<'\n';
tn=a;
}
//cout<<tn<<" "<<ca<<" "<<ci<<'\n';
}
for(int i=tg;i<N;i++){
cout<<0<<'\n';
}
return 0;
}
/* stuff you should look for
* int overflow, array bounds
* special cases (n=1,n=0?)
* do smth instead of nothing and stay organized
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |