Submission #640107

#TimeUsernameProblemLanguageResultExecution timeMemory
640107shishankrawat93774Job Scheduling (CEOI12_jobs)C++14
0 / 100
177 ms18956 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,popcnt,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; typedef unsigned long long ull; typedef long double lld; #define fo(iter, start_value, less_than) for(int iter = start_value; iter<less_than; iter++) #define noans cout<<"-1" #define zero cout<<"0" #define nline "\n" #define space " " #define MSBll(n) __lg(n) #define vi vector<int> #define vpii vector<pair<int, int> > #define vvi vector<vector<int> > #define set_bits __builtin_popcountll #define getunique(x) {sort(all(x)); x.erase(unique(all(x)), x.end());} #define mem(x, val) memset(x, val, sizeof(x)) // const double PI = 3.141592653589793238462; // const int MOD = 1e9+7; // const int MOD = 998244353; // const ll INF = 1e18; const int N = 1e6+6; // const int N = 2e5+5; // const int N = 3e5+5; // const int MX = INT_MAX; // const int MN = INT_MIN; #define yes cout<<"YES" #define no cout<<"NO" struct point{ int x; int id; }; int n, ex, days; vector<point> arr(N+1); bool chk(int x){ int d = 1, i = x; while(i<=n){ if(d <= arr[i].x + ex){ i += x; d++; }else{ return false; } } return true; } void fun(){ cin>>days>>ex>>n; arr.resize(n+1); for(int i = 1; i<=n; i++){ cin>>arr[i].x; arr[i].id = i; } sort(arr.begin() + 1, arr.end(), [](point p1, point p2){ return p1.x < p2.x; }); int l = 1, r = n; while(l<=r){ int mid = l + (r-l)/2; if(chk(mid)){ r = mid - 1; }else{ l = mid + 1; } } int rq = r+1; vector<vector<int> > ans; for(int i = 1; i<=n;){ int cnt = 0; vector<int> tmp; while(i<=n and cnt<rq){ tmp.push_back(arr[i].id); cnt++; i++; } ans.push_back(tmp); } cout<<rq<<nline; for(auto v: ans){ for(int x: v) cout<<x<<space; cout<<"0 "<<nline; } for(int i = ans.size(); i<days; i++) zero<<nline; } signed main() { // #ifndef ONLINE_JUDGE // freopen("Error.txt", "w", stderr); // #endif fastio(); int _CASE = 1; // int _TC = 1;cin>>_TC;while(_TC--) // cout<<"Case #"<<_CASE++<<": ", fun(),cout<<"\n"; return 0; }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:108:9: warning: unused variable '_CASE' [-Wunused-variable]
  108 |     int _CASE = 1;
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...