题目链接:http://acm.tju.edu.cn/toj/showp3778.html
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 1123 Accepted Runs: 398 Multiple test files
Description
In the American movie "Big Bang", Sheldon has 4 friends(Penny, Leonard, Raj and Howard). One day, he want to build a new friendship with one guy named Kripke so that he can use Kripke's new machine(which is called open science grid computer blablablablabla...). But he find it is difficult to maintain five friendships, so, he is going to let one of them go. (What a boy...)
Every friend has one value (v[i] = value * value) in Sheldon's mind, and he may get a new friend with v[i](v[i] = value * value) or delete a friend with the lowest v[i]. There are at most 100000 people.
Input
Each input has 2 type of operations:
- A: n val, which means Sheldon gets a "new friend" with value val.
- B: r, which means Sheldon want to delete one of his friend with lowest v[i] (PAY ATTENTION v[i] = value * value BUT NOT value).
Input is end with EOF.
Output
Output one number, the HIGHEST v[i] of remaining friends of Sheldon. (PAY ATTENTION, print v[i] = value * value BUT NOT value)
Sample Input
n 1 n 2 r n 35 n 32 r n 34 r
Sample Output
1225
哎,感觉自己水的不要不要的~~~,做这个题一直在纠结存储结果和去掉最小值。。。。完全没有意义直接求最大值不久可以了嘛!
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
char a;
int b,max = 0;
while(cin >> a){
if (a == 'n'){
cin >> b;
if (b > max){
max = b;
}
}
}
printf("%d\n",max*max);
return 0;
}