Submission #591331

#TimeUsernameProblemLanguageResultExecution timeMemory
591331YassineBenYounesJob Scheduling (CEOI12_jobs)C++17
0 / 100
373 ms17132 KiB
/* ID: Yassine BenYounes TASK: maxcross LANG: C++ */ #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef double db; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM) ll modd(ll x, ll n){while(x < 0){x += n;}return (x % n);} // modulo for negative numbers #define endl "\n" #define ss second #define ff first #define all(x) (x).begin() , (x).end() #define pb push_back #define vi vector<int> #define vii vector<pair<int,int>> #define vl vector<ll> #define vll vector<pair<ll,ll>> #define pii pair<int,int> #define pll pair<ll,ll> #define pdd pair<double,double> #define vdd vector<pdd> #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 2*1e5 + 9; const ll mod = 1e9+7; const ll inf = 1e15; int n;int d;int m; vii v; bool f(int t){ int day = 1; for(int i = 1; i <= m;i++){ if(day - v[i].ff > t)return 0; if(i % t == 0)day++; } return 1; } int solve(){ int low = 1; int high = 1e9 + 9; int ans = 0; while(low <= high){ ll mid = low + (high - low) / 2; if(f(mid)){ ans = mid; high = mid-1; } else{ low = mid+1; } } return ans; } int main(){ speed; cin >> n >> d >> m; v.pb({0, 0}); for(int i = 0; i < m;i++){ int x;cin >> x; v.pb({x, i+1}); } sort(all(v)); int x = solve(); cout << x << endl; for(int i = 1; i <= m;i++){ cout << v[i].ss << " "; if(i % x == 0)cout << "0" << endl; } } /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! */

Compilation message (stderr)

jobs.cpp: In function 'void init()':
jobs.cpp:34:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:36:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...