目录 题目地址 题干 代码和解释 题目地址 Honk's pool(The Preliminary Contest for ICPC Asia Shenyang 2019 ) 题干 代码和解释 本题使用了STL multiset,它与 set 一样可以对元素自动排序,而与 set 不同的是能存多个值相同的元素. c++代码如下: #include<bits/stdc++.h> using namespace std; int main() { int n,k,x; int i; int tmp…
题目传送门 题意:训练指南P228 分析:照着书上的做法,把点插入后把它后面不占优势的点删除,S.size ()就是优势的人数,时间复杂度O (nlogn) #include <bits/stdc++.h> using namespace std; struct Point { int a, b; Point() {} Point(int a, int b) : a (a), b (b) {} bool operator < (const Point &r) const { re…
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 53106 Accepted: 17508 Description Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000)…
multiset的例子,允许集合内的元素是重复的 #include <iostream> #include <set> using namespace std; int main() { //定义一个降序的multiset multiset<int, greater<int> > mSet; //insert elements in random order mSet.insert(); mSet.insert(); mSet.insert(); mSet.…
The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 6020 Accepted Submission(s): 2436 Problem Description Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round…
一.set 在了解关联容器set之前,让我们先来看看下面这个例子,并猜测该例子输出什么: // stl/set1.cpp #include <iostream> #include <set> int main() { //type of the collection typedef std::set<int> IntSet; IntSet coll; //set container for int values /* insert elements from 1 to…