Submission #454928

# Submission time Handle Problem Language Result Execution time Memory
454928 2021-08-05T10:38:16 Z geometryisop Job Scheduling (CEOI12_jobs) C++14
0 / 100
1000 ms 23216 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=1000000000;
  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 116 ms 3224 KB Output isn't correct
2 Incorrect 119 ms 3120 KB Output isn't correct
3 Incorrect 112 ms 3148 KB Output isn't correct
4 Incorrect 113 ms 3128 KB Output isn't correct
5 Incorrect 179 ms 3116 KB Output isn't correct
6 Incorrect 149 ms 3260 KB Output isn't correct
7 Incorrect 117 ms 3128 KB Output isn't correct
8 Incorrect 323 ms 3256 KB Output isn't correct
9 Execution timed out 1078 ms 11092 KB Time limit exceeded
10 Execution timed out 1018 ms 11356 KB Time limit exceeded
11 Incorrect 52 ms 2592 KB Output isn't correct
12 Incorrect 98 ms 4724 KB Output isn't correct
13 Incorrect 163 ms 7176 KB Output isn't correct
14 Incorrect 379 ms 10192 KB Output isn't correct
15 Incorrect 241 ms 11104 KB Output isn't correct
16 Incorrect 642 ms 14576 KB Output isn't correct
17 Incorrect 618 ms 17280 KB Output isn't correct
18 Incorrect 511 ms 17332 KB Output isn't correct
19 Execution timed out 1069 ms 23216 KB Time limit exceeded
20 Incorrect 514 ms 17368 KB Output isn't correct