Submission #745489

#TimeUsernameProblemLanguageResultExecution timeMemory
745489NafeeszxJob Scheduling (CEOI12_jobs)C++14
0 / 100
79 ms10956 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define trav(a, x) for(auto& a : x) #define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++) #define ROF(i, a, b) for (int i=(a); i>=(signed)(b); i--) #define F0R(i, a) for (int i=0; i<(signed)(a); i++) #define vi vector<int> #define f first #define s second #define all(v) (v).begin(), (v).end() typedef long long ll; const int mod = 1e9 + 7, MOD = 998244353; const int N = 2005; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m, d; cin >> n >> d >> m; vector<int> v(m); vector<vector<int>> tind(n-d+1); F0R(i, m) { cin >> v[i]; tind[v[i]].push_back(i); } int hi = m, lo = 0; while(hi - lo > 1) { int mid = (hi+lo)/2; bool ok = true; int c = 0; FOR(i, 1, n-d) { if(c + tind[i].size() > mid * (d+1)) { ok = false; break; } c = max(0, c+(int)tind[i].size()-mid); } //cout << mid << '\n'; if(ok) hi=mid; else lo=mid; } cout << hi << '\n'; return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:36:35: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |             if(c + tind[i].size() > mid * (d+1)) {
      |                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...