//zjnu 1399
//sort 数组可用
//vector sort(vector)
#include<iostream>
#include<algorithm>
using namespace std;
int s[];
int main()
{
int n;
int i;
int k=;
while(scanf("%d",&n)&&n!=-)
{
k++;
for(i=;i<n;i++)
scanf("%d",&s[i]);
sort(s,s+n);
printf("Case number:%d\n",k);
printf("Number of elements:%d\n",n);
for(i=;i<n-;i++)
printf("%d ",s[i]);
printf("%d\n",s[n-]);
}
}
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
using namespace std;
int main()
{
vector<int>a;
int n,x,k=;
while(scanf("%d",&n)&&n!=-)
{
a.clear();
for(int i=;i<n;i++)
{
scanf("%d",&x);
a.push_back(x);
}
sort(a.begin(),a.end());//vector的sort用法
printf("Case number:%d\n",++k);
printf("Number of elements:%d\n",n);
for(int i=;i<a.size()-;i++)
printf("%d ",a[i]);
printf("%d\n",a[a.size()-]);
}
system("pause");
}
//zjnu 1042 map
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
map<int,int>cl;
map<int,int>::iterator it;
int a[];
int main()
{
int n;
while(~scanf("%d",&n))
{
int i,x;
cl.clear();
for(i=;i<=n;i++)
{
scanf("%d",&x);
cl[x]++;
}
for(it=cl.begin();it!=cl.end();it++)
{
printf("%d %d\n",(*it).first,(*it).second);
}//first 指向x的值 second指向 cl[]的值
}
return ;
}
//zjnu 1407
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
struct node{
int x,y,z;
}s[];
bool cmp(node a,node b)
{
if(a.x==b.x&&a.y==b.y)
return a.z<b.z;
if(a.x==b.x)
return a.y<b.y;
return a.x<b.x;
}
int main()
{
int t,n,i;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].z);
}
sort(s,s+n,cmp);
printf("%d\n",n);
for(i=;i<n;i++)
printf("%d %d %d\n",s[i].x,s[i].y,s[i].z);
}
}
//zjnu 1403 全排列
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[];
int main()
{
int n,m,i,j;
while(~scanf("%d%d",&n,&m))
{
for(i=;i<n;i++)
a[i]=i+;
for(j=;j<m;j++)
next_permutation(a,a+n);
for(i=;i<n-;i++)
printf("%d ",a[i]);
printf("%d\n",a[n-]);
}
return ;
}
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
struct node{
int num,rank;
friend bool operator<(node a,node b)
{
if(a.rank==b.rank)
return a.num>b.num;//在后面的优先级高
return a.rank<b.rank;
}
};
int main()
{
int t,i,n,m;
char s[];
node x;
while(~scanf("%d",&t))
{
priority_queue<node>q[];//每次都要重新定义队列
int id=;
while(t--)
{
scanf("%s",s);
if(s[]=='I')
{
scanf("%d%d",&n,&m);
x.rank=m;
x.num=id++;
q[n].push(x);
}
else
{
scanf("%d",&n);
if(q[n].empty())
printf("EMPTY\n");
else
{
printf("%d\n",q[n].top().num);
q[n].pop();
}
}
}
}
return ;
}