제출 #649509

#제출 시각아이디문제언어결과실행 시간메모리
649509ShirleyMJob Scheduling (CEOI12_jobs)C++14
0 / 100
1095 ms65536 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; typedef vector<bool> vb; typedef vector<vb> vvb; #define x first #define y second #define pb push_back #define loop(i,s,e) for(int i=s;i<e;i++) #define loopr(i,s,e) for(int i=e-1; i>=s;i--) #define chkmax(a,b) a=max(a,b) #define chkmin(a,b) a=min(a,b) #define all(a) a.begin(),a.end() #define fast {ios_base::sync_with_stdio(0); cin.tie(0);} const int inf = 1e18; const int INF = 1e9; int n, d, m; int32_t main() { fast; cin >> n >> d >> m; vector<set<int>> starts_in(n+1); vector<set<int>> ends_in(n+1); vi rel_days; vi tasks(m); loop(i,0,m){ cin >> tasks[i]; int s=tasks[i], e=s+d; starts_in[s].insert(i); ends_in[e].insert(i); } loop(i,1,n+1) if(!starts_in[i].empty()) rel_days.pb(i); int cnt_tasks=0; int cnt_machine=0; vvi tasks_per_day(n+1); while(cnt_tasks<m){ cnt_machine++; set<ii> cur_tasks; auto p_day = 0; int cur_day=0; while(cur_day<=n && (p_day < rel_days.size() || !cur_tasks.empty())){ if(cur_tasks.empty()){ cur_day = rel_days[p_day]; p_day++; } else if(cur_day == rel_days[p_day]) p_day++; //inserting today's tasks if(!starts_in[cur_day].empty()){ cur_tasks.insert({cur_day+d, starts_in[cur_day].size()}); } //finding current task ii cur = *cur_tasks.begin(); int cur_day_t = cur.x, cur_cnt_t = cur.y; cur_tasks.erase(cur_tasks.begin()); if(cur_cnt_t > 1) cur_tasks.insert({cur_day_t, cur_cnt_t-1}); int cur_t = *(ends_in[cur_day_t].begin()); tasks_per_day[cur_day].pb(cur_t); starts_in[tasks[cur_t]].erase(starts_in[tasks[cur_t]].find(cur_t)); ends_in[cur_day_t].erase(ends_in[cur_day_t].begin()); //erasing tasks that end today auto ers = cur_tasks.lower_bound({cur_day,1}); if(ers != cur_tasks.end() && (*ers).x == cur_day){ cur_tasks.erase(ers); } cnt_tasks++; cur_day++; } rel_days.clear(); loop(i,1,n+1) if(!starts_in[i].empty()) rel_days.pb(i); } cout << cnt_machine << endl; loop(i,1,n+1){ for(int t: tasks_per_day[i]) cout << t+1 << " "; cout << "0\n"; } return 0; }

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

jobs.cpp: In function 'int32_t main()':
jobs.cpp:53:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         while(cur_day<=n && (p_day < rel_days.size() || !cur_tasks.empty())){
      |                              ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...