Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>using namespace std;template<class T>inline void read(T &x){char c;x=1;while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;T res=c-'0';while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';x*=res;}int T,N,R,ans;int heap[2510],h;struct node{int A,P;}coins[5010];bool cmpNode(node x,node y){return x.A<y.A;}void maintain(){int i=0,j,k,l=1;while(i<l){i=l;j=i*2;k=j+1;if(j<=h && heap[j]<heap[l])l=j;if(k<=h && heap[k]<heap[l])l=k;if(i<l)swap(heap[i],heap[l]);}}void push(int x){