Submission #442245

# Submission time Handle Problem Language Result Execution time Memory
442245 2021-07-07T10:37:57 Z cpp219 Job Scheduling (CEOI12_jobs) C++14
0 / 100
61 ms 8268 KB
#pragma GCC optimization O2
#pragma GCC optimization "unroll-loop"
#pragma target ("avx2")

#include <bits/stdc++.h>
#define ll int
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e5 + 9;
const ll Log2 = 20;
const ll inf = 1e9 + 7;

ll n,m,d,a[N],pos[N];

bool lf(ll x,ll y){
    return a[x] < a[y];
}

vector<ll> ans[N];

bool chk(ll mid){
    ll cur = 1;
    for (ll day = 1;day <= n;day++){
        ll have = mid; ans[day].clear();
        while(have > 0 && cur <= m&&a[pos[cur]] <= day){
            if (day - a[pos[cur]] > d) return 0;
            ans[day].push_back(pos[cur]); cur++; have--;
        }
        ans[day].push_back(0);
    }
    return 1;
}

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>n>>d>>m;
    for (ll i = 1;i <= m;i++) cin>>a[i],pos[i] = i;
    sort(pos + 1,pos + m + 1,lf);
    ll l,mid,h; l = 1; h = m;
    //cout<<chk(2); return 0;
    while(l <= h){
        mid = (l + h)/2;
        if (chk(mid)) h = mid - 1;
        else l = mid + 1;
    }
    cout<<l<<"\n"; chk(l); //return 0;
    for (ll i = 1;i <= n;i++){
        for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
    }
}

Compilation message

jobs.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
jobs.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
jobs.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
jobs.cpp: In function 'int main()':
jobs.cpp:56:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   56 |         for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
      |         ^~~
jobs.cpp:56:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   56 |         for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
      |                                             ^~~~
jobs.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 5060 KB Expected EOLN
2 Incorrect 30 ms 5044 KB Expected EOLN
3 Incorrect 30 ms 4976 KB Expected EOLN
4 Incorrect 31 ms 5080 KB Expected EOLN
5 Incorrect 30 ms 5064 KB Expected EOLN
6 Incorrect 31 ms 4960 KB Expected EOLN
7 Incorrect 31 ms 5068 KB Expected EOLN
8 Incorrect 31 ms 5036 KB Expected EOLN
9 Incorrect 61 ms 8228 KB Expected EOLN
10 Incorrect 54 ms 8268 KB Expected EOLN
11 Incorrect 37 ms 4848 KB Expected EOLN
12 Incorrect 11 ms 4068 KB Output isn't correct
13 Incorrect 11 ms 4088 KB Output isn't correct
14 Incorrect 18 ms 4428 KB Output isn't correct
15 Incorrect 12 ms 4100 KB Output isn't correct
16 Incorrect 17 ms 4428 KB Output isn't correct
17 Incorrect 18 ms 4324 KB Output isn't correct
18 Incorrect 12 ms 4308 KB Output isn't correct
19 Incorrect 32 ms 7392 KB Output isn't correct
20 Incorrect 17 ms 4416 KB Output isn't correct