Submission #670419

#TimeUsernameProblemLanguageResultExecution timeMemory
670419asdf334Job Scheduling (CEOI12_jobs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define sz(x) (int)x.size() int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, D, M; cin >> N >> D >> M; map<int, vector<int>> vals; for (int i = 1; i <= M; ++i) { int num; cin >> num; vals[num].push_back(i); } int left = 1; int right = 1e6; while (left < right) { int mid = left + (right - left) / 2; ll curr = 0; int del = 0; for (auto val : vals) { curr = max(curr, mid * (val.first - 1)); curr += sz(val.second); del = max(del, (int)ceil(curr / mid) - val.first); } if (del > D) { left = mid + 1; } else { right = mid; } } cout << left << '\n'; int ctr = 0; vector<vector<int>> ans(N); for (auto val : vals) { for (int num : val.second) { if (sz(ans[ctr]) >= left) ++ctr; ans[ctr].push_back(num); } } for (vector<int> day : ans) { for (int req : day) { cout << req << " "; } cout << 0 << '\n'; } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:18:42: error: no matching function for call to 'max(ll&, int)'
   18 |    curr = max(curr, mid * (val.first - 1)); curr += sz(val.second);
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
jobs.cpp:18:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |    curr = max(curr, mid * (val.first - 1)); curr += sz(val.second);
      |                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
jobs.cpp:18:42: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |    curr = max(curr, mid * (val.first - 1)); curr += sz(val.second);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
jobs.cpp:18:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |    curr = max(curr, mid * (val.first - 1)); curr += sz(val.second);
      |                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
jobs.cpp:18:42: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |    curr = max(curr, mid * (val.first - 1)); curr += sz(val.second);
      |                                          ^