Submission #305202

#TimeUsernameProblemLanguageResultExecution timeMemory
305202updown1Job Scheduling (CEOI12_jobs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<int,int> pi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define f first #define s second ll N, D, M; bool check(vector<ll> x, int m) { vector<ll> machT(m); F0R(i, M) { machT[i % m] = max(machT[i % m] + 1, x[i]); if (machT[i % m] > x[i] + D) { return false; } } return true; } ll binary_search(vector<ll> x) { ll r = N; ll l = 1; while (l != r) { int mid = (l + r)/2; if (check(x, mid)) { r = mid; } else { l = mid + 1; } } return l; } int main() { cin >> N >> D >> M; vector<ll> jobs(M); vector<pair<ll, int>> jp(M); F0R(i, M) { cin >> jobs[i]; jp[i] = {jobs[i], i}; } sort(all(jobs)); sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;} return a.f < b.f;}); ll machines = binary_search(jobs); cout << machines << endl; /*vector<vector<int>> sim(N + 1); vector<ll> machT(machines); F0R(i, M) { machT[i % machines] = max(machT[i % machines] + 1, jobs[i]); sim[machT[i % machines]].pb(jp[i].s + 1); } FOR(i, 1, N + 1) { F0R(j, sim[i].size()) { cout << sim[i][j] << " "; } cout << 0 << endl; }*/ }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:61:10: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   61 |     sort(all(jobs));
      |          ^~~
      |          std::filesystem::perms::all
In file included from /usr/include/c++/9/filesystem:36,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:129,
                 from jobs.cpp:1:
/usr/include/c++/9/bits/fs_fwd.h:147:7: note: 'std::filesystem::perms::all' declared here
  147 |       all  =  0777,
      |       ^~~
jobs.cpp:62:22: error: 'pl' has not been declared
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                      ^~
jobs.cpp:62:28: error: 'pl' has not been declared
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                            ^~
jobs.cpp: In lambda function:
jobs.cpp:14:11: error: request for member 'first' in 'a', which is of non-class type 'int'
   14 | #define f first
      |           ^~~~~
jobs.cpp:62:41: note: in expansion of macro 'f'
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                                         ^
jobs.cpp:14:11: error: request for member 'first' in 'b', which is of non-class type 'int'
   14 | #define f first
      |           ^~~~~
jobs.cpp:62:48: note: in expansion of macro 'f'
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                                                ^
jobs.cpp:15:11: error: request for member 'second' in 'a', which is of non-class type 'int'
   15 | #define s second
      |           ^~~~~~
jobs.cpp:62:61: note: in expansion of macro 's'
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                                                             ^
jobs.cpp:15:11: error: request for member 'second' in 'b', which is of non-class type 'int'
   15 | #define s second
      |           ^~~~~~
jobs.cpp:62:67: note: in expansion of macro 's'
   62 |     sort(all(jp), [](pl a, pl b) {if (a.f == b.f) {return a.s > b.s;}
      |                                                                   ^
jobs.cpp:14:11: error: request for member 'first' in 'a', which is of non-class type 'int'
   14 | #define f first
      |           ^~~~~
jobs.cpp:63:14: note: in expansion of macro 'f'
   63 |     return a.f < b.f;});
      |              ^
jobs.cpp:14:11: error: request for member 'first' in 'b', which is of non-class type 'int'
   14 | #define f first
      |           ^~~~~
jobs.cpp:63:20: note: in expansion of macro 'f'
   63 |     return a.f < b.f;});
      |                    ^