답안 #986597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986597 2024-05-20T20:37:42 Z kojac Job Scheduling (CEOI12_jobs) C++17
컴파일 오류
0 ms 0 KB
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
 
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second
#define pb push_back
#define endl "\n"
 
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 2e5 + 5;
const ll MOD = 1e9+7;
const ll p = 333;
 
 
int32_t main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); cout.tie(NULL);
 
    // freopen("angry.in","r",stdin);
    // freopen("angry.out","w",stdout);
 
 
 
 
 
    // int tt; cin >> tt;
 
 
    // while(tt--){
 
    // }
	

   int n, d, m;
   vector<int> v;

    cin >> n >> d >> m;

    for(int i = 0; i < m; i++){
        int x;

        cin >> x;

        v.push_back({x, i+1});
    }

    sort(v.begin(), v.end());


    int l = 1, r = m, ans;
    
    priority_queue<int, vector<int>, greater<int>> fila;

    while(l <= r){
        int mid = (l+r)/2;

        bool foi = true;

        while(!fila.empty())fila.pop();
        

        for(int i = 0; i < mid; i++) fila.push(v[i].F+1);

        for(int i = mid; i < m; i++){
            int aux = fila.top();
            fila.pop();
            if(aux-v[i].F > d){
                foi = false;
                break;
            }else{
                fila.push(max(aux,v[i].F)+1);
            }

        }

        if(foi){
            ans = mid;
            r = mid-1;
        }else l = mid+1;
    }

    while(!fila.empty()) fila.pop();
    vector<int> resp[n+5];

    for(int i = 0; i < ans; i++){
        fila.push(v[i].F+1);
        resp[v[i].F].push_back(v[i].S);
    }

    for(int i = ans; i < m; i++){
        ll aux = fila.top();
        fila.pop();

        fila.push(max(aux,v[i].F)+1);

        resp[max(aux,v[i].F)].push_back(v[i].S);
    }

    cout << ans << endl;

    for(int i = 1; i <= n; i++){
        for(int j = 0; j < resp[i].size(); j++){
            cout << resp[i][j] << " ";
        }

        cout << "0\n";
    }
 
   

    
 
	
 
    
    
    return 0;
}

Compilation message

jobs.cpp: In function 'int32_t main()':
jobs.cpp:53:29: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   53 |         v.push_back({x, i+1});
      |                             ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jobs.cpp:4:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:71:53: note: in expansion of macro 'F'
   71 |         for(int i = 0; i < mid; i++) fila.push(v[i].F+1);
      |                                                     ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:76:25: note: in expansion of macro 'F'
   76 |             if(aux-v[i].F > d){
      |                         ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:80:40: note: in expansion of macro 'F'
   80 |                 fila.push(max(aux,v[i].F)+1);
      |                                        ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:95:24: note: in expansion of macro 'F'
   95 |         fila.push(v[i].F+1);
      |                        ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:96:19: note: in expansion of macro 'F'
   96 |         resp[v[i].F].push_back(v[i].S);
      |                   ^
jobs.cpp:8:11: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    8 | #define S second
      |           ^~~~~~
jobs.cpp:96:37: note: in expansion of macro 'S'
   96 |         resp[v[i].F].push_back(v[i].S);
      |                                     ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:103:32: note: in expansion of macro 'F'
  103 |         fila.push(max(aux,v[i].F)+1);
      |                                ^
jobs.cpp:7:11: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    7 | #define F first
      |           ^~~~~
jobs.cpp:105:27: note: in expansion of macro 'F'
  105 |         resp[max(aux,v[i].F)].push_back(v[i].S);
      |                           ^
jobs.cpp:8:11: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    8 | #define S second
      |           ^~~~~~
jobs.cpp:105:46: note: in expansion of macro 'S'
  105 |         resp[max(aux,v[i].F)].push_back(v[i].S);
      |                                              ^
jobs.cpp:111:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |         for(int j = 0; j < resp[i].size(); j++){
      |                        ~~^~~~~~~~~~~~~~~~