促销活动 (Hoax or what,UVa 11136)

 1 #include <iostream>
 2 #include <string.h>
 3 #include <string>
 4 #include <fstream>
 5 #include <algorithm>
 6 #include <stdio.h>
 7 #include <vector>
 8 #include <queue>
 9 #include <set>
10 #include <cmath>
11 using namespace std;
12 const double eps = 1e-8;
13 const double pi=acos(-1.0);
14 const int INF=0x7fffffff;
15 unsigned long long uINF = ~0LL;
16 #define MAXN 1007
17 #define mod 1000000007
18 typedef long long LL;
19 multiset<int> s;
20 int main()
21 {
22     int n,k;
23     while(scanf("%d",&n),n!=0)
24     {
25         s.clear();
26         int ans=0,temp;
27         for(int i=0;i<n;i++)
28         {
29         scanf("%d",&k);
30         for(int j=0;j<k;j++)
31         {
32             scanf("%d",&temp);
33             s.insert(temp);
34         }
35         int minn,maxx;
36         if(s.size()>0)
37         {
38             multiset<int>::iterator it;
39             it=s.begin();minn=*it;
40             it=s.end();it--;maxx=*it;
41             s.erase(it);
42             if(s.size()>0)
43             {
44                 it=s.begin();
45                 s.erase(it);
46             }
47             ans+=maxx-minn;
48         }
49         }
50         printf("%d\n",ans);
51     }
52 
53     return 0;
54 }

提交不了 暂存 下次提交

转载于:https://www.cnblogs.com/TO-Asia/p/3224750.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值