Skip to content

Instantly share code, notes, and snippets.

@MagallanesFito
Last active January 5, 2016 09:56
Show Gist options
  • Save MagallanesFito/07e5edc1b8010adbf9af to your computer and use it in GitHub Desktop.
Save MagallanesFito/07e5edc1b8010adbf9af to your computer and use it in GitHub Desktop.
Canguros Problema Preselectivo
#include <iostream>
#include <queue>
#define op_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
op_io
int n,c;
cin>>c>>n;
char comando;
long long actual;
queue<long long> canguros;
while(n--){
cin>>comando;
switch(comando){
case 'N':
cin>>actual;
canguros.push(actual);
break;
case 'A':
c-=canguros.front() + 1;
canguros.pop();
break;
case 'C':
cout << canguros.size() << "\n";
break;
case 'R':
cout << c << "\n";
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment