C. Alyona and mex
http://codeforces.com/contest/740/problem/C
构造思维题。
第一直觉就是区间长度+1的最小值就是答案。
然而不知道怎么去构造这个序列、
其实就是每个区间,都要包含0、1、2、3、...ans - 1即可。
所以,只要不断0、1、2、3、4、...ans - 1、0、1、2、3、....这样放即可。
因为最小的区间长度是ans - 1,那么选出来的区间只能比这个大,那么拿到绝对包含了0、1、2、3、4...ans - 1
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
const int maxn = 1e5 + ;
struct node {
int L, R;
int val;
bool operator < (const struct node & rhs) const {
if (val != rhs.val) return val < rhs.val;
else if (R != rhs.R) return R > rhs.R;
else return L > rhs.L;
}
} q[maxn];
int a[maxn];
int vis[maxn];
int n, m; void work() {
IOS;
cin >> n >> m;
int ans = inf;
for (int i = ; i <= m; ++i) {
cin >> q[i].L >> q[i].R;
q[i].val = q[i].R - q[i].L + ;
ans = min(ans, q[i].val);
}
cout << ans << endl;
int to = ;
for (int i = ; i <= n; ++i) {
cout << to << " ";
to++;
to %= ans;
}
} int main() {
#ifdef local
freopen("data.txt","r",stdin);
#endif
work();
return ;
}
C. Alyona and mex的更多相关文章
- Codeforces Round #381 (Div. 2)C. Alyona and mex(思维)
C. Alyona and mex Problem Description: Alyona's mother wants to present an array of n non-negative i ...
- Codeforces 740C. Alyona and mex 思路模拟
C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...
- Codeforces Round #381 (Div. 1) A. Alyona and mex 构造
A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother want ...
- Codeforces Round #358 (Div. 2)B. Alyona and Mex
B. Alyona and Mex time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- CodeForces 682B Alyona and Mex (排序+离散化)
Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...
- Alyona and mex
Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题
B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...
- CF | Alyona and Mex
Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyon ...
- Codeforces Round #381 (Div. 2)C Alyona and mex
Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be ...
- B - Alyona and Mex
Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one oper ...
随机推荐
- node js 安装时选择勾上path
勾上path则会自动配置环境变量,否则必须手动去添加nodejs的环境变量.
- ReactMotion Demo8 分析
链接 首先通过spring函数Motion的style参数, 传入Motion Component, 计算style的过程: const style = lastPressed === i & ...
- vue中手机号,邮箱正则验证以及60s发送验证码
今天写了一个简单的验证,本来前面用的组件,但是感觉写的组件在此项目不是很好用,由于用到的地方比较少,所以直接写在了页面中.页面展示如图 <div> <p class=&quo ...
- 多线程、死锁、线程安全、同步方法、代码块、休眠、守护线程、Thread、Runnable(二十三)
1.多线程的引入 * 1.什么是线程 * 线程是程序执行的一条路径, 一个进程中可以包含多条线程 * 多线程并发执行可以提高程序的效率, 可以同时完成多项工作* 2.多线程的应用场景 * 红蜘蛛同时共 ...
- 让 SyntaxHighlighter 3.x 支持 Lua 语法着色
1. [代码]shBrushLua.js /** * SyntaxHighlighter * http://alexgorbatchev.com/SyntaxHighlighter * * Synta ...
- html5--6-6 CSS选择器3
html5--6-6 CSS选择器3 实例 学习要点 掌握常用的CSS选择器 了解不太常用的CSS选择器 什么是选择器 当我们定义一条样式时候,这条样式会作用于网页当中的某些元素,所谓选择器就是样式作 ...
- [置顶] SQL Server 2005 双机热备的实现
[置顶] SQL Server 2005 双机热备的实现 分类: SQLSERVER2011-08-24 21:25 901人阅读 评论(0) 收藏 举报 sql servermicrosoftsql ...
- 创建一个Windows Service 程序
1.新建Windows项目,选择"Windows服务"类型的项目. 2.在生成的Service1.cs中代码中写你需要的代码,如下: using System; using Sys ...
- ASP.NET Core:Pages
ylbtech-ASP.NET Core:Pages 1.返回顶部 1._Layout.cshtm <!DOCTYPE html> <html> <head> &l ...
- Java调用Static修饰的本类方法
public class Dy { public static void main(String[] args){ int a=6; int b=5; int result=0; result=Add ...