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的更多相关文章

  1. 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 ...

  2. Codeforces 740C. Alyona and mex 思路模拟

    C. Alyona and mex time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...

  3. 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 ...

  4. 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 ...

  5. CodeForces 682B Alyona and Mex (排序+离散化)

    Alyona and Mex 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/B Description Someone gave ...

  6. Alyona and mex

    Alyona and mex time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. 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 ...

  8. CF | Alyona and Mex

    Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one operation, Alyon ...

  9. 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 ...

  10. B - Alyona and Mex

    Description Someone gave Alyona an array containing n positive integers a1, a2, ..., an. In one oper ...

随机推荐

  1. ubuntu 本地和服务器scp文件传输

    安装 SSH(Secure Shell) 服务以提供远程管理服务 sudo apt-get install ssh SSH 远程登入 Ubuntu 机 ssh username@192.168.0.1 ...

  2. searchkick HasMany Associations | index related model fields

    Project < ActiveRecord::Base searchkick has_many :categories_has_projects has_many :categories, t ...

  3. redis03----link 链表操作

    link 链表结构 之前是操作字符串string 链表:头元素,后面一个一个的指向后面的元素.Redis内部实现了链表的结构.链表的头尾,从一个元素找到另外的元素. 链表的名字也是一个key. flu ...

  4. jQuery常用插件大全(9)ResponsiveSlides插件

    ResponsiveSlides.js是一个展示同一容器内图片的轻量级响应式jQuery幻灯片插件(tiny responsive slideshow jQuery plugin).它支持包括IE6在 ...

  5. 一步一步学Silverlight 2系列(26):基本图形

    概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, ...

  6. MongoDb复制集实现故障转移,读写分离

    前言 数据库技术是信息系统的一个核心技术,发展很快,各种功能类型数据库层出不穷,之前工作中使用过关系型数据库(mysql.oracle等).面相对象数据库(db4o).key-value存储(Memc ...

  7. const常量

    1.不能给常量赋值 ; a=; 编译器报错:“a”: 不能给常量赋值

  8. vmware实现与windows下的共享文件

    1 首先你得先设置一下windows下得共享 比如是准备共享D盘 那么右击 ----->属性------->高级共享勾上就OK勒 2那么vmware怎么设置呢? 打开vmware-> ...

  9. c++ 头文件 及 sort 和 vector简单介绍

    c++  sort :http://www.16kan.com/post/997260.html http://wenku.baidu.com/view/e064166daf1ffc4ffe47ac6 ...

  10. Docker容器日志管理最佳实践

    目录 一 .Docker 引擎日志 二.容器日志 2.1.常用查看日志命令--docker logs 2.2 .Docker 日志 驱动 三. 生产环境中该如何储存容器中的日志 一.当是完全是标准输出 ...