Submission #104875

# Submission time Handle Problem Language Result Execution time Memory
104875 2019-04-09T12:28:43 Z daili Job Scheduling (CEOI12_jobs) C++14
0 / 100
224 ms 8672 KB
#include <bits/stdc++.h>

using namespace std;

bool check(int x, int n, vector<pair<int,int>> &allJobs, bool finall, int m, int d)
{
	int ptr = 1;
	for(int i = 1; i <= n;i++)
	{
      int ct = 0;
      while(ptr <= m && allJobs[ptr].first <= i && ct < x)
      {
          if(allJobs[ptr].first + d >= i)
          {
              ptr++;
          }
          else
          {
              return false;
          }
          if(finall)
          {
              cout << allJobs[ptr-1].second << " ";
          }
          ct++;
      }
      if(finall)
      {
          cout << 0 << "\n";
      }
	}
	if(ptr <= m)
	{
    return false;
  }
	return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, d, m;
    cin >> n >> d >> m;

    vector<pair<int,int>> allJobs;
    allJobs.push_back({0, 0});
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        allJobs.push_back({x, i+1});
    }

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

    int left = 0;
    int right = m;

    while(left < right)
    {
        int mid = (left + right) >> 1;

        if (check(mid, n, allJobs, 0, m, d))
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
    cout << left << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 1532 KB Unexpected end of file - int32 expected
2 Incorrect 15 ms 1404 KB Unexpected end of file - int32 expected
3 Incorrect 15 ms 1532 KB Unexpected end of file - int32 expected
4 Incorrect 14 ms 1532 KB Unexpected end of file - int32 expected
5 Incorrect 16 ms 1532 KB Unexpected end of file - int32 expected
6 Incorrect 16 ms 1532 KB Unexpected end of file - int32 expected
7 Incorrect 15 ms 1532 KB Unexpected end of file - int32 expected
8 Incorrect 16 ms 1532 KB Unexpected end of file - int32 expected
9 Incorrect 22 ms 1532 KB Unexpected end of file - int32 expected
10 Incorrect 22 ms 1532 KB Unexpected end of file - int32 expected
11 Incorrect 32 ms 1532 KB Unexpected end of file - int32 expected
12 Incorrect 42 ms 2552 KB Unexpected end of file - int32 expected
13 Incorrect 78 ms 4588 KB Unexpected end of file - int32 expected
14 Incorrect 94 ms 4596 KB Unexpected end of file - int32 expected
15 Incorrect 106 ms 4588 KB Unexpected end of file - int32 expected
16 Incorrect 160 ms 8648 KB Unexpected end of file - int32 expected
17 Incorrect 167 ms 8672 KB Unexpected end of file - int32 expected
18 Incorrect 194 ms 8672 KB Unexpected end of file - int32 expected
19 Incorrect 224 ms 8672 KB Unexpected end of file - int32 expected
20 Incorrect 200 ms 8672 KB Unexpected end of file - int32 expected