Submission #1004377

#TimeUsernameProblemLanguageResultExecution timeMemory
1004377u_suck_oJob Scheduling (CEOI12_jobs)C++17
Compilation error
0 ms0 KiB
#include <iostream> //#include <vector> //#include <queue> #define MAXN 100005 using namespace std; int n, d, m; vector<int> tasks[MAXN]; int main() { cin >> n >> d >> m; for (int i = 1; i <= m; i++) { int x; cin >> x; tasks[x].push_back(i); } //binary search on answer int l = 1, r = m; while (l < r) { int mid = (l+r)/2; queue<pair<int, int>> q; bool valid = true; for (int i = 1; i <= n; i++) { for (int j : tasks[i]) q.push({j, i}); for (int j = 1; j <= mid; j++) { if (!q.empty()) { auto p = q.front(); q.pop(); if (i - p.second > d) { valid = false; break; } } else break; } if (!valid) break; } if (!q.empty()) valid = false; if (valid) r = mid; else l = mid+1; } cout << r << "\n"; //make assignments queue<pair<int, int>> q; vector<int> v[n]; for (int i = 1; i <= n; i++) { for (int j : tasks[i]) q.push({j, i}); for (int j = 1; j <= r; j++) { if (!q.empty()) { v[i].push_back(q.front().first); q.pop(); } else break; } } for (int i = 1; i <= n; i++) { for (int j : v[i]) cout << j << " "; cout << "0\n"; } }

Compilation message (stderr)

jobs.cpp:9:1: error: 'vector' does not name a type
    9 | vector<int> tasks[MAXN];
      | ^~~~~~
jobs.cpp: In function 'int main()':
jobs.cpp:15:9: error: 'tasks' was not declared in this scope
   15 |         tasks[x].push_back(i);
      |         ^~~~~
jobs.cpp:21:9: error: 'queue' was not declared in this scope
   21 |         queue<pair<int, int>> q;
      |         ^~~~~
jobs.cpp:2:1: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
    1 | #include <iostream>
  +++ |+#include <queue>
    2 | //#include <vector>
jobs.cpp:21:28: error: expected primary-expression before '>' token
   21 |         queue<pair<int, int>> q;
      |                            ^~
jobs.cpp:21:31: error: 'q' was not declared in this scope
   21 |         queue<pair<int, int>> q;
      |                               ^
jobs.cpp:24:26: error: 'tasks' was not declared in this scope
   24 |             for (int j : tasks[i])
      |                          ^~~~~
jobs.cpp:49:5: error: 'queue' was not declared in this scope
   49 |     queue<pair<int, int>> q;
      |     ^~~~~
jobs.cpp:49:5: note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?
jobs.cpp:49:24: error: expected primary-expression before '>' token
   49 |     queue<pair<int, int>> q;
      |                        ^~
jobs.cpp:49:27: error: 'q' was not declared in this scope
   49 |     queue<pair<int, int>> q;
      |                           ^
jobs.cpp:50:5: error: 'vector' was not declared in this scope
   50 |     vector<int> v[n];
      |     ^~~~~~
jobs.cpp:2:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | //#include <vector>
jobs.cpp:50:12: error: expected primary-expression before 'int'
   50 |     vector<int> v[n];
      |            ^~~
jobs.cpp:52:22: error: 'tasks' was not declared in this scope
   52 |         for (int j : tasks[i])
      |                      ^~~~~
jobs.cpp:56:17: error: 'v' was not declared in this scope
   56 |                 v[i].push_back(q.front().first);
      |                 ^
jobs.cpp:64:22: error: 'v' was not declared in this scope
   64 |         for (int j : v[i])
      |                      ^