Submission #708525

#TimeUsernameProblemLanguageResultExecution timeMemory
708525jsathu07Job Scheduling (CEOI12_jobs)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long ll; bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m) { ll j = 0; bool p = true; for (ll i = 0; i < n; i++) { ll y = x; while (y-- && j < m) { if (!(i + 1 <= arr[j] + d)) { p = false; break; } // cout << "day " << i + 1 << " processed " << j + 1 << " \n"; j++; } if (!p) break; } return p; } void solve() { ll n, d, m; cin >> n >> d >> m; vector<ll> arr(m, 0); vector<pair<ll, ll>> brr; for (ll i = 0; i < m; i++) { cin >> arr[i]; brr.push_back({arr[i], i + 1}); } sort(brr.begin(), brr.end()); sort(arr.begin(), arr.end()); ll l = 1, r = 1e15, ans = 1e6; while (l <= r) { ll mid = (l + r) / 2; if (calc(n, d, mid, arr, m)) { ans = mid; r = mid - 1; } else { l = mid + 1; } } cout << ans << "\n"; ll k = 0, rem = 0; for (auto &i : brr) { if (k == ans) { cout << 0 << "\n"; k = 0; rem++; } cout << i.second << " "; k++; } rem++; cout << 0 << "\n"; ll q = n - rem; while (q > 0) { cout << 0 << "\n"; q--; } } // void setIO(string s) // { // freopen((s + ".in").c_str(), "r", stdin); // freopen((s + ".out").c_str(), "w", stdout); // } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }

Compilation message (stderr)

jobs.cpp:3:21: error: expected ';' before 'll'
    3 | using ll = long long ll;
      |                     ^~~
      |                     ;
jobs.cpp:5:11: error: 'll' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |           ^~
jobs.cpp:5:17: error: 'll' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                 ^~
jobs.cpp:5:23: error: 'll' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                       ^~
jobs.cpp:5:36: error: 'll' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                                    ^~
jobs.cpp:5:38: error: template argument 1 is invalid
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                                      ^
jobs.cpp:5:38: error: template argument 2 is invalid
jobs.cpp:5:41: error: 'arr' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                                         ^~~
jobs.cpp:5:46: error: 'll' was not declared in this scope
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                                              ^~
jobs.cpp:5:50: error: expression list treated as compound expression in initializer [-fpermissive]
    5 | bool calc(ll n, ll d, ll x, vector<ll> &arr, ll m)
      |                                                  ^
jobs.cpp: In function 'void solve()':
jobs.cpp:30:5: error: 'll' was not declared in this scope
   30 |     ll n, d, m;
      |     ^~
jobs.cpp:31:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   31 |     cin >> n >> d >> m;
      |            ^
      |            yn
jobs.cpp:31:17: error: 'd' was not declared in this scope
   31 |     cin >> n >> d >> m;
      |                 ^
jobs.cpp:31:22: error: 'm' was not declared in this scope; did you mean 'tm'?
   31 |     cin >> n >> d >> m;
      |                      ^
      |                      tm
jobs.cpp:32:14: error: template argument 2 is invalid
   32 |     vector<ll> arr(m, 0);
      |              ^
jobs.cpp:32:24: error: expression list treated as compound expression in initializer [-fpermissive]
   32 |     vector<ll> arr(m, 0);
      |                        ^
jobs.cpp:33:23: error: template argument 1 is invalid
   33 |     vector<pair<ll, ll>> brr;
      |                       ^~
jobs.cpp:33:23: error: template argument 2 is invalid
jobs.cpp:34:12: error: expected ';' before 'i'
   34 |     for (ll i = 0; i < m; i++)
      |            ^~
      |            ;
jobs.cpp:34:20: error: 'i' was not declared in this scope
   34 |     for (ll i = 0; i < m; i++)
      |                    ^
jobs.cpp:37:13: error: request for member 'push_back' in 'brr', which is of non-class type 'int'
   37 |         brr.push_back({arr[i], i + 1});
      |             ^~~~~~~~~
jobs.cpp:39:14: error: request for member 'begin' in 'brr', which is of non-class type 'int'
   39 |     sort(brr.begin(), brr.end());
      |              ^~~~~
jobs.cpp:39:27: error: request for member 'end' in 'brr', which is of non-class type 'int'
   39 |     sort(brr.begin(), brr.end());
      |                           ^~~
jobs.cpp:40:14: error: request for member 'begin' in 'arr', which is of non-class type 'int'
   40 |     sort(arr.begin(), arr.end());
      |              ^~~~~
jobs.cpp:40:27: error: request for member 'end' in 'arr', which is of non-class type 'int'
   40 |     sort(arr.begin(), arr.end());
      |                           ^~~
jobs.cpp:41:7: error: expected ';' before 'l'
   41 |     ll l = 1, r = 1e15, ans = 1e6;
      |       ^~
      |       ;
jobs.cpp:42:12: error: 'l' was not declared in this scope
   42 |     while (l <= r)
      |            ^
jobs.cpp:42:17: error: 'r' was not declared in this scope
   42 |     while (l <= r)
      |                 ^
jobs.cpp:44:11: error: expected ';' before 'mid'
   44 |         ll mid = (l + r) / 2;
      |           ^~~~
      |           ;
jobs.cpp:45:24: error: 'mid' was not declared in this scope
   45 |         if (calc(n, d, mid, arr, m))
      |                        ^~~
jobs.cpp:45:35: error: 'calc' cannot be used as a function
   45 |         if (calc(n, d, mid, arr, m))
      |                                   ^
jobs.cpp:47:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   47 |             ans = mid;
      |             ^~~
      |             abs
jobs.cpp:55:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   55 |     cout << ans << "\n";
      |             ^~~
      |             abs
jobs.cpp:56:7: error: expected ';' before 'k'
   56 |     ll k = 0, rem = 0;
      |       ^~
      |       ;
jobs.cpp:57:20: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   57 |     for (auto &i : brr)
      |                    ^~~
      |                    std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
jobs.cpp:57:20: error: 'end' was not declared in this scope; did you mean 'std::end'?
   57 |     for (auto &i : brr)
      |                    ^~~
      |                    std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
jobs.cpp:59:13: error: 'k' was not declared in this scope
   59 |         if (k == ans)
      |             ^
jobs.cpp:63:13: error: 'rem' was not declared in this scope; did you mean 'drem'?
   63 |             rem++;
      |             ^~~
      |             drem
jobs.cpp:66:9: error: 'k' was not declared in this scope
   66 |         k++;
      |         ^
jobs.cpp:68:5: error: 'rem' was not declared in this scope; did you mean 'drem'?
   68 |     rem++;
      |     ^~~
      |     drem
jobs.cpp:70:7: error: expected ';' before 'q'
   70 |     ll q = n - rem;
      |       ^~
      |       ;
jobs.cpp:71:12: error: 'q' was not declared in this scope
   71 |     while (q > 0)
      |            ^