Submission #742963

# Submission time Handle Problem Language Result Execution time Memory
742963 2023-05-17T07:01:35 Z vjudge1 Job Scheduling (CEOI12_jobs) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

struct data
{
    int day,work,dead;
    bool operator<(const data&d2)const{
        return day<d2.day;
    }
};

vector<data> vc,copys;
int n,d,m,a,l = 1,r = 1e9,ans = 1e9+7;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin>>n>>d>>m;
    for(int i = 1; i<=m; ++i){
        cin>>a;
        vc.push_back({a,i,a+d});
    }
    sort(vc.begin(), vc.end());
    for(auto [day,work,dead]:vc){
        //cout<<day<<" "<<work<<" "<<dead<<"\n";
        copys.push_back({day,work,dead});
    }
    //cout<<"----------------------\n";
    while(l<r){
        int mid = (l+r)>>1;
        int cnt = 0;
        bool ck = 0;
        for(int i = 0; i<vc.size(); ++i){
            if(vc[i].day==vc[i].dead){
                ck = 1;
                break;
            }
            ++cnt;
            if(cnt==mid){
                cnt = 0;
                for(int j = i+1; j<vc.size(); ++j){
                    vc[j].day++;
                    if(vc[j].day==vc[j].dead){
                        ck = 1;
                        break;
                    }
                }
            }
            if(ck) break;
        }
        if(ck) l = mid+1;
        else r = mid;
        vc = copys;
    }
    int k = m/l;
    cout<<k<<"\n";
    int cnt = 0,c = 0;
    for(auto [day,work,dead]:vc){
        if(cnt==k){
            cnt = 0;
            ++c;
            cout<<0<<"\n";
        }
        ++cnt;
        cout<<work<<" ";
    }
    if(c!=m) cout<<0<<"\n";
    for(int i = 0; i<n-l; ++i) cout<<0<<"\n ";
}

Compilation message

jobs.cpp:13:12: error: template argument 1 is invalid
   13 | vector<data> vc,copys;
      |            ^
jobs.cpp:13:12: error: template argument 2 is invalid
jobs.cpp: In function 'int main()':
jobs.cpp:22:12: error: request for member 'push_back' in 'vc', which is of non-class type 'int'
   22 |         vc.push_back({a,i,a+d});
      |            ^~~~~~~~~
jobs.cpp:24:13: error: request for member 'begin' in 'vc', which is of non-class type 'int'
   24 |     sort(vc.begin(), vc.end());
      |             ^~~~~
jobs.cpp:24:25: error: request for member 'end' in 'vc', which is of non-class type 'int'
   24 |     sort(vc.begin(), vc.end());
      |                         ^~~
jobs.cpp:25:30: error: 'begin' was not declared in this scope
   25 |     for(auto [day,work,dead]:vc){
      |                              ^~
jobs.cpp:25:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
jobs.cpp:25:30: error: 'end' was not declared in this scope
   25 |     for(auto [day,work,dead]:vc){
      |                              ^~
jobs.cpp:25:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~
jobs.cpp:27:15: error: request for member 'push_back' in 'copys', which is of non-class type 'int'
   27 |         copys.push_back({day,work,dead});
      |               ^~~~~~~~~
jobs.cpp:34:29: error: request for member 'size' in 'vc', which is of non-class type 'int'
   34 |         for(int i = 0; i<vc.size(); ++i){
      |                             ^~~~
jobs.cpp:35:18: error: invalid types 'int[int]' for array subscript
   35 |             if(vc[i].day==vc[i].dead){
      |                  ^
jobs.cpp:35:29: error: invalid types 'int[int]' for array subscript
   35 |             if(vc[i].day==vc[i].dead){
      |                             ^
jobs.cpp:42:39: error: request for member 'size' in 'vc', which is of non-class type 'int'
   42 |                 for(int j = i+1; j<vc.size(); ++j){
      |                                       ^~~~
jobs.cpp:43:23: error: invalid types 'int[int]' for array subscript
   43 |                     vc[j].day++;
      |                       ^
jobs.cpp:44:26: error: invalid types 'int[int]' for array subscript
   44 |                     if(vc[j].day==vc[j].dead){
      |                          ^
jobs.cpp:44:37: error: invalid types 'int[int]' for array subscript
   44 |                     if(vc[j].day==vc[j].dead){
      |                                     ^
jobs.cpp:59:30: error: 'begin' was not declared in this scope
   59 |     for(auto [day,work,dead]:vc){
      |                              ^~
jobs.cpp:59:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1224:5: note:   'std::begin'
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:549:3: note:   'std::filesystem::__cxx11::begin'
  549 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
jobs.cpp:59:30: error: 'end' was not declared in this scope
   59 |     for(auto [day,work,dead]:vc){
      |                              ^~
jobs.cpp:59:30: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from jobs.cpp:1:
/usr/include/c++/10/valarray:1244:5: note:   'std::end'
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
In file included from /usr/include/c++/10/filesystem:46,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from jobs.cpp:1:
/usr/include/c++/10/bits/fs_dir.h:554:3: note:   'std::filesystem::__cxx11::end'
  554 |   end(recursive_directory_iterator) noexcept
      |   ^~~