Submission #454923

# Submission time Handle Problem Language Result Execution time Memory
454923 2021-08-05T10:36:56 Z geometryisop Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 26704 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,d,m;
  cin>>n>>d>>m;
  ll a[m];
  vector< vector<int>> vii;
  map <ll,ll> mp;
  vii.assign(n+5,vector<int>());
  for (int i=0;i<m;i++)
  {
      cin>>a[i];
     // cout<<a[i]<<endl;
      vii[a[i]].push_back(i+1);
      mp[a[i]]++;
  }
 // cout<<vii[1][0];
  //cout<<" "<<vii[1][1]<<endl;
  ll l=0;
  ll r=1000000;
  ll ans=r;
  while(l<=r)
  {
      ll mid=(l+r)/2;
      //check if works for mid
      ll machines=mid;
      ll deadline=n-d;
      ll up=mid;
      bool flag=true;
      for (int i=deadline;i>=1;i--)
      {
          if (up-mp[i]>=0)
          {
              up-=mp[i];
              up+=mid;
          }
          else
          {
              flag=false;
              break;
          }
      }
      if (flag)
      {
          ans=min(ans,mid);
          r=mid-1;
      }
      else
        l=mid+1;

  }
  vector <int> v;
  cout<<ans<<endl;  ll cnt=0;
  for (int i=1;i<=n;i++)
  {
      if (i>n-d)
      {
          cout<<0<<endl;
      }
      else
      {
          bool allakse=false;

          for (int j=0;j<vii[i].size();j++)
          {
            cout<<vii[i][j]<<" ";
              cnt++;
              if (cnt==ans)
              {
                  cnt=0;
                  cout<<0<<endl;
                  allakse=true;//allakse i mera;
              }
          }
          if (!allakse)
          {
              cout<<0<<endl;
              cnt=0;
          }
      }
  }
  return 0;
}

Compilation message

jobs.cpp: In function 'int main()':
jobs.cpp:28:10: warning: unused variable 'machines' [-Wunused-variable]
   28 |       ll machines=mid;
      |          ^~~~~~~~
jobs.cpp:66:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |           for (int j=0;j<vii[i].size();j++)
      |                        ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 100 ms 2940 KB Output isn't correct
2 Incorrect 108 ms 3040 KB Output isn't correct
3 Incorrect 98 ms 2888 KB Output isn't correct
4 Incorrect 108 ms 2936 KB Output isn't correct
5 Incorrect 111 ms 2924 KB Output isn't correct
6 Incorrect 117 ms 2940 KB Output isn't correct
7 Incorrect 116 ms 2940 KB Output isn't correct
8 Incorrect 109 ms 2832 KB Output isn't correct
9 Incorrect 750 ms 11132 KB Output isn't correct
10 Incorrect 739 ms 11088 KB Output isn't correct
11 Incorrect 56 ms 2348 KB Output isn't correct
12 Incorrect 113 ms 4276 KB Output isn't correct
13 Incorrect 155 ms 6912 KB Output isn't correct
14 Incorrect 306 ms 9968 KB Output isn't correct
15 Incorrect 237 ms 10788 KB Output isn't correct
16 Incorrect 554 ms 14448 KB Output isn't correct
17 Incorrect 582 ms 17144 KB Output isn't correct
18 Incorrect 645 ms 17160 KB Output isn't correct
19 Execution timed out 1058 ms 26704 KB Time limit exceeded
20 Incorrect 690 ms 17204 KB Output isn't correct