Skip to content

Instantly share code, notes, and snippets.

@chalubhalu
Last active September 17, 2015 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chalubhalu/af0ef183730bc0c53aa4 to your computer and use it in GitHub Desktop.
Save chalubhalu/af0ef183730bc0c53aa4 to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
//9 to 6
int main()
{
int i, j, k, t, n, m;
cin >> n >> m;
vector<vector<int>> assigned(n);
vector<int> time_room(n, 18);
vector<int> meet[4][4];
for (i = 0; i < m; ++i)
{
cin >> j >> k;
if (k % 30 == 0)
--k;
k /= 30;
meet[j][k].push_back(i);
}
for (i = 0; i < n; ++i)
{
for (j = 1; j <= 3; ++j)
{
for (k = 0; k < 4; ++k)
{
for (int x = 0; x < meet[j][k].size(); ++x)
{
if (time_room[i] >= k + 1 && meet[j][k][x]!=-1)
{
assigned[i].push_back(meet[j][k][x]);
time_room[i] -= (k + 1);
meet[j][k][x] = -1;
}
}
}
}
}
for (i = 0; i < n; ++i)
{
for (j = 0; j < assigned[i].size(); ++j)
cout << assigned[i][j] << " ";
cout << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment