제출 #78621

#제출 시각아이디문제언어결과실행 시간메모리
78621ekremJob Scheduling (CEOI12_jobs)C++98
30 / 100
1088 ms33792 KiB
#include <bits/stdc++.h> #define st first #define nd second #define mp make_pair #define pb push_back #define orta ((bas+son)/2) #define N 1000005 using namespace std; typedef pair < int , int > ii; int n, m, d, bas = 1, son, l, r, q[N], a[N]; vector < int > g[N]; bool dene(int x){ l = 1; r = 0; int ind = 1; for(int i = 1; i <= n; i++){ for(int j = 0; j < g[i].size(); j++){ q[++r] = i; ind++; } int say = 0; for(int j = 1; j <= x; j++) if(r - l + 1 > 0){ if(i - q[l] > d) return 0; else l++; } } if(r - l + 1 > 0) return 0; return 1; } void bastir(int x){ l = 1; r = 0; int ind = 1; for(int i = 1; i <= n; i++){ for(int j = 0; j < g[i].size(); j++){ q[++r] = g[i][j]; ind++; } int say = 0; for(int j = 1; j <= x; j++) if(r - l + 1 > 0){ cout << q[l] << " "; l++; } cout << 0 << endl; } } int main() { // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); scanf("%d %d %d",&n ,&d ,&m); son = m; for(int i = 1; i <= m; i++){ scanf("%d",&a[i]); g[a[i]].pb(i); } while(bas < son) if(dene(orta)) son = orta; else bas = orta + 1; cout << orta << endl; bastir(orta); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'bool dene(int)':
jobs.cpp:18:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < g[i].size(); j++){
                  ~~^~~~~~~~~~~~~
jobs.cpp:22:7: warning: unused variable 'say' [-Wunused-variable]
   int say = 0;
       ^~~
jobs.cpp: In function 'void bastir(int)':
jobs.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < g[i].size(); j++){
                  ~~^~~~~~~~~~~~~
jobs.cpp:45:7: warning: unused variable 'say' [-Wunused-variable]
   int say = 0;
       ^~~
jobs.cpp: In function 'int main()':
jobs.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n ,&d ,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...