Submission #454918

# Submission time Handle Problem Language Result Execution time Memory
454918 2021-08-05T10:35:11 Z geometryisop Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 27212 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;
          }
      }
  }
  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 98 ms 3120 KB Output isn't correct
2 Incorrect 96 ms 3208 KB Output isn't correct
3 Incorrect 107 ms 3164 KB Output isn't correct
4 Incorrect 100 ms 3264 KB Output isn't correct
5 Incorrect 105 ms 3128 KB Output isn't correct
6 Incorrect 95 ms 3132 KB Output isn't correct
7 Incorrect 101 ms 3260 KB Output isn't correct
8 Incorrect 99 ms 3132 KB Output isn't correct
9 Incorrect 695 ms 11388 KB Output isn't correct
10 Incorrect 742 ms 11336 KB Output isn't correct
11 Incorrect 49 ms 2624 KB Output isn't correct
12 Incorrect 97 ms 4900 KB Output isn't correct
13 Incorrect 160 ms 7512 KB Output isn't correct
14 Incorrect 324 ms 10584 KB Output isn't correct
15 Incorrect 241 ms 11544 KB Output isn't correct
16 Incorrect 406 ms 15140 KB Output isn't correct
17 Incorrect 478 ms 17756 KB Output isn't correct
18 Incorrect 429 ms 17820 KB Output isn't correct
19 Execution timed out 1061 ms 27212 KB Time limit exceeded
20 Incorrect 467 ms 17828 KB Output isn't correct