제출 #696755

#제출 시각아이디문제언어결과실행 시간메모리
696755koolaiderJob Scheduling (CEOI12_jobs)C++17
0 / 100
323 ms13912 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 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; v.pb({x, i+1}); } sort(v.begin(), v.end()); //debug(v); int l=1, r=m-1; int ans = MN; while(l<=r){ int mid=(l+r)/2; int curr=m-(n*mid); if(curr>0){ l=mid+1; }else if(curr<=0){ int currDay=0; int Clock=0; bool isOk=true; for(int i = 0; i<m; i++){ if(v[i].first+d>currDay){ isOk=false; break; } Clock++; if(Clock==mid){ currDay++; Clock=0; } } if(isOk==true){ ans=min(ans, mid); } 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; } } for(int i = 0; i<n-ceil(m/ans); i++){ cout << 0 << endl; } return 0; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */

컴파일 시 표준 에러 (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...