题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5349
1 #include<stdio.h> 2 int main(){ 3 int cnt; 4 int max; 5 int N; 6 int ch; 7 while(~scanf("%d",&N)){ 8 cnt = 0; 9 while(N--){ 10 scanf("%d",&ch); 11 if(ch==1){ 12 scanf("%d",&ch); 13 if(cnt==0) 14 max = ch; 15 cnt++; 16 max = ch > max ? ch :max; 17 continue; 18 } 19 if(ch==2&&cnt!=0) 20 cnt--; 21 if(ch==3&&cnt!=0) 22 printf("%d\n",max); 23 if(ch==3&&cnt==0) 24 printf("0\n"); 25 } 26 } 27 }
1 #include<stdio.h> 2 #include<cstring> 3 #include<set> 4 using namespace std; 5 int main() 6 { 7 multiset<int>s; 8 int T; 9 int n, t; 10 while(~scanf("%d",&T)){ 11 while(T--){ 12 scanf("%d",&n); 13 switch(n){ 14 case 1: 15 scanf("%d",&t); 16 s.insert(t); 17 break; 18 case 2: 19 if(!s.empty()) 20 s.erase(*s.begin()); 21 break; 22 case 3: 23 if(s.empty()) 24 printf("0\n"); 25 else 26 printf("%d\n",*--s.end()); 27 break; 28 } 29 } 30 } 31 }
hdoj 5349 MZL's simple problem
时间: 2024-10-12 13:03:47