TOJ 3778.Sheldon's Friendship II

题目链接:http://acm.tju.edu.cn/toj/showp3778.html

3778.    Sheldon's Friendship II
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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值