Codeforces Round #381 (Div. 2)C. Alyona and mex(构造题,好题)
来源:互联网 发布:pageoffice java 编辑:程序博客网 时间:2024/04/30 00:42
题意
给你n个非负数,然后m个区间,你需要构造n个数,使得这m个区间的mex最小值最大。
区间的mex是取不在该区间集合中的最小的非负数。
题解:
其实答案只和区间长度有关,区间最短长度就是答案,序列按照0123......0123这样去构造,那个区间总能够包含0到那么多的数的。
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<vector>using namespace std;#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define pb push_back#define mp make_pair#define fi first#define se secondtypedef vector<int> VI;typedef long long ll;typedef pair<int,int> PII;const ll mod=1000000007;const int INF=0x3fffffff;int main(){int n,m;cin >> n >> m;int ans=INF;while(m--){int l,r;cin >> l >> r;ans=min(ans,r-l+1);}int cnt=0;cout << ans << endl;rep(i,1,n+1){printf("%d ",cnt);cnt++;cnt%=ans;}return 0;}
0 0
- Codeforces Round #381 (Div. 2)C. Alyona and mex(构造题,好题)
- Codeforces Round #381 (Div. 2)C - Alyona and mex
- Codeforces Round #381 (Div. 2) C. Alyona and mex
- Codeforces Round #381 (Div. 2)C. Alyona and mex
- Codeforces Round #381 (Div. 2)-C. Alyona and mex
- Codeforces Round #381 (Div. 2) C. Alyona and mex 贪心+构造
- Codeforces Round #381 (Div. 2) C Alyona and mex (构造)
- Codeforces#381(Div. 2) C. Alyona and mex【思维】好题~
- Codeforces Round #381 (Div. 2) Alyona and mex
- Codeforces Round #381C. Alyona and mex
- Codeforces Round #381 (Div. 2) C. Alyona and mex(思维)
- Codeforces Round #381 (Div. 2) C. Alyona and mex(模拟)
- Codeforces Round #381 (Div. 2) C. Alyona and mex(思维)
- CodeForces 740C Alyona and mex 简单构造题
- Codeforces Round #358 (Div. 2) -- B. Alyona and Mex (思路水题)
- Codeforces Round #381 (Div. 1) A. Alyona and mex
- Codeforces Round #358 (Div. 2) B. Alyona and Mex
- Codeforces Round #358 (Div. 2) B. Alyona and Mex
- 恢复linux里被误删除的文件
- 18. 4Sum
- 交换机的划分方式
- Spring AOP:面向切面编程
- 153. Find Minimum in Rotated Sorted Array
- Codeforces Round #381 (Div. 2)C. Alyona and mex(构造题,好题)
- 程序员的书籍资源
- ajax 同步请求和异步请求的区别
- jQuery的text()和html()讲解
- 交换机为什么需要划分AP、AG和SW三个层?
- WEB-INF下的JSP是不能通过URL直接访问的
- SparseArray源码分析
- git从白痴到菜鸟
- 矩阵的乘法算法