제출 #581595

#제출 시각아이디문제언어결과실행 시간메모리
581595gcconureJob Scheduling (CEOI12_jobs)C++17
60 / 100
1097 ms19496 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n,d,m; vector<pair<ll,ll>> v; bool ok(ll dd){ int day = 1, w = 0; while(day<=n){ for(int i = 0; i < dd; i++){ w++; if(w==v.size()){ return true; } if(day>v[w].first+d){ return false; } if(day<v[w].first){ w--; } } day++; } return false; } int main(){ cin >> n >> d >> m; for(ll i = 0; i < m; i++){ ll x; cin >> x; v.push_back({x,i}); } sort(v.begin(), v.end()); ll l = 1,r=m; while(l<r){ ll mid = (l+r)/2; if(ok(mid)){ r=mid; } else{ l=mid+1; } } reverse(v.begin(), v.end()); ll counter =0 ; cout << l << "\n"; while(!v.empty()){ counter++; for(ll i = 0; i < l; i++){ cout << v.back().second+1 << " "; v.pop_back(); if(v.empty()){ break; } } cout << "0\n"; } for(ll i = 0; i < n-counter; i++){ cout << 0 << "\n"; } }

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

jobs.cpp: In function 'bool ok(ll)':
jobs.cpp:13:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |             if(w==v.size()){
      |                ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...