Submission #442248

#TimeUsernameProblemLanguageResultExecution timeMemory
442248cpp219Job Scheduling (CEOI12_jobs)C++14
0 / 100
279 ms30936 KiB
#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 = 1e6 + 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 (stderr)

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:57:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |         for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
      |         ^~~
jobs.cpp:57:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   57 |         for (auto j : ans[i]) cout<<j<<" "; cout<<"\n";
      |                                             ^~~~
jobs.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...