---
# System prepended metadata

title: UVa 11136 - Hoax or what
tags: [林基成-C++, UVA code, cpp, Awwwolf的刷題之路]

---

# UVa 11136 - Hoax or what 
## Online Judge
![](https://i.imgur.com/zHt15iu.png)

## 解題思路
看得懂題目就有思路了。
## 解題中出現的bug
Wrong Answer 的部分
1. Answer用int會overflow
2. 再刪除set裡的數字時，要注意容器裡是否為空 p.s.尤其是第25行
## Code
```cpp=
#include <iostream>
#include <set>
using namespace std;

int main()
{
    int Cases;
    int n, m;
    while(cin >> Cases && Cases!=0)
    {
        multiset<int> bills;
        long long int case_answer = 0;
        while(Cases--)
        {
            cin >> n;
            for(int i=0;i<n;i++)
            {
                cin >> m;
                bills.insert(m);
            }
            if(!bills.empty())
            {
                case_answer += *(--bills.end()) - *bills.begin();
                bills.erase(bills.begin());
                if(!bills.empty())
                    bills.erase(--bills.end());
            }
        }
        cout << case_answer << endl;
    }
    return 0;
}

```
###### tags: `UVA code` `cpp` `林基成-C++` `Awwwolf的刷題之路`