Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.