Skip to content

Instantly share code, notes, and snippets.

@taikoubou
Created December 12, 2013 16:26
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 taikoubou/7930801 to your computer and use it in GitHub Desktop.
Save taikoubou/7930801 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<algorithm>
#include<vector>
int level[101],exp[101],num[101];
using namespace std;
int main(){
int N,M;
cin >> N >> M;
for(int i=1;i<=N;i++){
level[i] = 1;
num[i] = i;
}
for(int i=0;i<M;i++){
int tmp,tmp_2;
cin >> tmp;
cin >> tmp_2;
exp[tmp]+=tmp_2;
if(exp[tmp] >= 100*level[tmp]){
level[tmp]++;
exp[tmp] = 0;
}
}
/*for(int i=1;i<=N;i++){
while(exp[i] >= 100*level[i]){
level[i]++;
exp[i] -= 100*level[i];
*if(exp[i] < 0){
level[i]--;
break;
}*
}
}*/
for(int i=1;i<N;i++){
for(int j=i+1;j<=N;j++){
if(level[i] < level[j]){
level[i] ^= level[j];
level[j] ^= level[i];
level[i] ^= level[j];
num[i] ^= num[j];
num[j] ^= num[i];
num[i] ^= num[j];
}
else if(level[i] == level[j] && num[i] > num[j]){
level[i] ^= level[j];
level[j] ^= level[i];
level[i] ^= level[j];
num[i] ^= num[j];
num[j] ^= num[i];
num[i] ^= num[j];
}
}
}
// for(int i=1;i<=N;i++)cout << level[i] << endl;
for(int i=1;i<=N;i++)cout << num[i] << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment