Submission #498065

#TimeUsernameProblemLanguageResultExecution timeMemory
498065MohamedAliSaidaneJob Scheduling (CEOI12_jobs)C++14
20 / 100
183 ms26020 KiB
#pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<ld,ld> pld; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<pld> vpd; #define pb push_back #define popb pop_back #define all(v) (v).begin(),(v).end() #define ff first #define ss second const ll MOD = 1e9 + 7; const ll INF = 1e18; int nx[4] = {1,-1,0,0}, ny[4] = {0,0,1,-1}; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;} int n, d, m; vpi req; vector<vi> feas; vector<vi> cur; bool test(int x) { int prec = 0; vector<vi> tuc; for(int i= 1; i <= n; i ++) { vi day; for(int j = prec; j < min(prec + x,m); j ++) { if(i - req[j].ff > d) { return false; } day.pb(req[j].ss); } day.pb(0); tuc.pb(day); prec += x; } cur.clear(); cur = tuc; return true; } void solve() { cin >> n>> d >> m; for(int i = 0; i < m; i ++) { int x; cin >> x; req.pb({x,i+1}); } sort(all(req)); //for(auto e: req) // cout << e.ff << ' ' << e.ss << '\n'; int debut = 1; int fin = m; int ans = m; while(debut <= fin) { int mid = (debut+fin)/2; if(test(mid)) { ans = mid; fin = mid -1; } else debut = mid + 1; } cout << ans << '\n'; for(int i = 0; i < cur.size(); i ++) { for(int j = 0; j < cur[i].size(); j ++) { cout << cur[i][j]; if(j != cur[i].size()-1) cout << ' '; } if(i != cur.size() - 1) cout << '\n'; } } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int tt = 1; while(tt--) solve(); }

Compilation message (stderr)

jobs.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
jobs.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
jobs.cpp: In function 'void solve()':
jobs.cpp:86:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |     for(int i = 0; i < cur.size(); i ++)
      |                    ~~^~~~~~~~~~~~
jobs.cpp:88:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |         for(int j = 0; j < cur[i].size(); j ++)
      |                        ~~^~~~~~~~~~~~~~~
jobs.cpp:91:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |             if(j != cur[i].size()-1)
      |                ~~^~~~~~~~~~~~~~~~~~
jobs.cpp:94:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |         if(i != cur.size() - 1)
      |            ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...