题意 给你N个线段(一条直线上),问删去一个之后,最长公共长度 : 分析:首先我们得先知道n条线段公共的线段一定是(LMAX,RMIN) ,那我们可以先排序,然后枚举删除边: #include<stdio.h> #include<algorithm> using namespace std; struct no { int l,r; }a[]; ],r[]; int main( ) { int n; scanf("%d",&n); ; i<=n ;…
这道题,关键在于怎么求多个区间的交集,使用multiset就可以 分别将 r , l 存在不同的mutiset中. 然后,我们来看一下 是不是 交集的 l 是最大的, 交集的 r 是最小的 #include<iostream> #include<set> #include<algorithm> using namespace std; ; multiset<int>l, r; int n, x[maxn], y[maxn], ans; int main(){…
C. Maximal Intersection time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given nn segments on a number line; each endpoint of every segment has integer coordinates. Some segments ca…
Maximal Intersection time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given nn segments on a number line; each endpoint of every segment has integer coordinates. Some segments can d…
[链接]:CF [题意]:对任意一个数a[i] ,可以对任意 满足 i != j 且 a[i] > a[j] && a[i] <= a[j] +k 的 a[j] 可以被删掉,求使最终剩下的个数最少. [分析]:扫一遍,二分搜索合法的. [代码]: #include<cstdio> #include<string> #include<cstdlib> #include<cmath> #include<iostream>…
C. Pearls in a Row time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number…
B - Alice and Bob Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Alice and Bob's game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively.…
http://codeforces.com/contest/1029/problem/C You are given nn segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other o…
一道用STL的贪心,正好可以用来学习使用STL库 题目大意:给出n条可以内含,相交,分离的线段,如果重叠条数超过k次则为坏点,n,k<2e5 所以我们贪心的想我们从左往右遍历,如果重合部分条数超过了k,就必须去除线段,(此时从左边看去除线段后不会出现冲突,右边还有剩余很多线段未知)所以我们选择去除这些重合线段里右端最右的部分 实现: #include<bits/stdc++.h>using namespace std;typedef pair<int,int> pii;typ…
You are given n segments on a number line; each endpoint of every segment has integer coordinates. Some segments can degenerate to points. Segments can intersect with each other, be nested in each other or even coincide. The intersection of a sequenc…