Created
September 24, 2019 21:10
-
-
Save samyravitoria/5297905b97bb13bb8c4e43ce0ca44226 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOIC - Problemas da Semana 69 - Iniciante | |
// Solução por Samyra Almeida | |
#include <bits/stdc++.h> | |
using namespace std; | |
typedef long long ll; | |
int c, n, resp; | |
int main() | |
{ | |
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); | |
cin >> c >> n; | |
priority_queue<ll, vector<ll>, greater<ll> > caixas; | |
for(int i = 1 ; i <= c ; ++i) caixas.push(0); // adiciono todos os caixas na priority queue | |
for(int i = 0 ; i < n ; ++i) | |
{ | |
ll tempo_caixa = caixas.top(); // tiro o caixa que esta no topo da fila. | |
caixas.pop(); | |
ll t, d; | |
cin >> t >> d; | |
if(tempo_caixa < t) tempo_caixa += (t - tempo_caixa); // checo se o caixa fila "livre" por algum tempo. | |
if(tempo_caixa - t > 20) resp++; // se o cliente passou mais de 20 minutos esperando, incremento a resposta | |
tempo_caixa += d; // atualizo o tempo de atendimento do caixa | |
caixas.push(tempo_caixa); // o coloco novamente na fila | |
} | |
cout << resp << "\n"; // imprimo a resposta | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment