제출 #1327576

#제출 시각아이디문제언어결과실행 시간메모리
1327576hojiakbar2011Job Scheduling (CEOI12_jobs)C++20
40 / 100
197 ms31552 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define all(x) (x).begin(), (x).end()
#define ll long long
#define int long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
void setIO(string s) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    if (!s.empty()) {
        freopen((s + ".in").c_str(), "r", stdin);
        freopen((s + ".out").c_str(), "w", stdout);
    }
}
signed main() {
    setIO("");
    ll n, d, m;
    cin>>n>>d>>m;
    vector<vector<ll>> v(n);
    vector<ll> p(m);
    for(int i=0;i<m;i++){
        cin>>p[i];
        p[i]--;
        v[p[i]].pb(i);
    }
    
    
    ll l=1, r=m;
    while(l<r-1){
        ll mid=(l+r)/2;
        queue<ll> q;
        bool ok=1;
        for(int i=0;i<n;i++){
            for(auto u : v[i]) q.push(u);
            for(int j=0;j<mid;j++){
                if(!q.empty()){
                    if((p[q.front()]-i)>d){
                        ok=0;
                        break;
                    }
                    q.pop();
                }
                else break;
            }
            if(!ok) break;
        }
        if(!q.empty()) ok=0;
        if(ok) r=mid;
        else l=mid;
    }
    cout<<r<<"\n";
    queue<ll> q;
    for(int i=0;i<n;i++){
        for(auto u : v[i]) q.push(u);
        for(int j=0;j<r;j++){
            if(!q.empty()){
                cout<<q.front()+1<<" ";
                q.pop();
            }
        }
        cout<<0<<"\n";
    }

}

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

jobs.cpp: In function 'void setIO(std::string)':
jobs.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen((s + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen((s + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...