Submission #1042646

#TimeUsernameProblemLanguageResultExecution timeMemory
1042646joelgun14Job Scheduling (CEOI12_jobs)C++17
0 / 100
38 ms7664 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define endl "\n" #define ll long long #define mp make_pair #define ins insert #define lb lower_bound #define pb push_back #define ub upper_bound #define lll __int128 #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset; typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n, d, m; cin >> n >> d >> m; int a[m + 1]; for(int i = 1; i <= m; ++i) cin >> a[i]; sort(a + 1, a + n + 1); int cnt[n + 1]; memset(cnt, 0, sizeof(cnt)); for(int i = 1; i <= m; ++i) ++cnt[a[i]]; int l = 0, r = 1e6, ans = -1; while(l <= r) { int mid = (l + r) / 2; int pend = 0; for(int i = 1; i <= n; ++i) { pend += cnt[i]; pend -= mid; pend = max(pend, 0); } if(pend == 0) { r = mid - 1, ans = mid; } else l = mid + 1; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...