Submission #696963

#TimeUsernameProblemLanguageResultExecution timeMemory
696963koolaiderJob Scheduling (CEOI12_jobs)C++17
0 / 100
362 ms14388 KiB
#include <bits/stdc++.h> #include <cstdlib> using namespace std; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } #define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl #define pb push_back #define ll long long #define cint const int void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} //binar, dp, starcod, coci, / bfs, /seg /longest path template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef ONLINE_JUDGE #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif #pragma GCC target ("avx,avx2") #pragma GCC optimize ("O3") const long long ML = 1e18; cint MN = 1e9; cint MA = 2e5+1; cint MM = 1e9+7; int main(int argc, char **argv){ ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); int n, d, m; cin >> n >> d >> m; vector<pair<int, int>> v; int x; for(int i = 0; i<m; i++){ cin >> x; x--; v.pb({x, i+1}); } sort(v.begin(), v.end()); //debug(v); int l=1, r=m; int ans = MN; while(l<=r){ int mid=(l+r)/2; //int curr=m-(n*mid); int currDay=1; int Clock=0; bool isOk=true; for(int i = 0; i<m; i++){ if(currDay-v[i].first>d){//instead of d use time in queue isOk=false; break; } Clock++; if(Clock==mid){ currDay++; Clock=0; } } if(isOk==true){ ans=min(ans, mid); } if(isOk==false){//curr>0 l=mid+1; }else if(isOk==true){//curr<=0 r=mid-1; } } cout << ans << endl; int outputCounter=0; for(int i = 0; i<m; i++){ cout << v[i].second << " "; outputCounter++; if(outputCounter==ans){ cout << 0 << endl; outputCounter=0; }else if(i==m-1){ cout << 0 << endl; } } for(int i = 0; i<n-(m/ans); i++){ cout << 0 << endl; } return 0; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */

Compilation message (stderr)

jobs.cpp: In function 'void setIO(std::string)':
jobs.cpp:6:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  freopen((s + ".in").c_str(), "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen((s + ".out").c_str(), "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...