Submission #559190

#TimeUsernameProblemLanguageResultExecution timeMemory
559190CookieJob Scheduling (CEOI12_jobs)C++14
0 / 100
164 ms11332 KiB
#include <bits/stdc++.h> using namespace std; #define LIFESUCKS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ll long long #define ld long double #define ar array #include<cstdio> #define vt vector #include<fstream> ifstream fin("measurement.in"); ofstream fout("measurement.out"); #include<fstream> #define pb push_back #define all(c) (c).begin(), (c).end() //#define length(x) (int)(x).size() #define fi first #define se second #define vt vector using namespace std; int n, d, m; const int mxm = 1e6; vt<pair<int, int>>p; bool check(int mid){ int cr = 0; for(int i = 0; i < m; i += mid){ cr++; if(d + p[i].first < cr)return(false); } return(true); } int main() { LIFESUCKS; cin >> n >> d >> m; for(int i = 0; i < m; i++){ int x; cin >> x; p.pb({x, i + 1}); } sort(p.begin(), p.end()); int l = 1; int ans; int r = m; while(l <= r){ int mid = l + (r - l) / 2; if(check(mid)){ ans = mid; r = mid - 1; }else{ l = mid + 1; } } cout << ans; return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:51:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   51 |    cout << ans;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...