C - Covered Points Count

emmm 好像是先离散化一下 注意 R需要+1 这样可以确定端点

emmm 扫描线?瞎搞一下?

#include<bits/stdc++.h>
using namespace std;
#define maxn 4000005
#define LL long long
LL  a[maxn],b[maxn],ll[maxn],rr[maxn],c[maxn];
LL  x[maxn],y[maxn];
vector<LL >q;
int main(){
   LL  n;
   cin>>n;
   ;j<n;j++){
      cin>>a[j]>>b[j];
      b[j]++;
      q.push_back(a[j]);
      q.push_back(b[j]);
   }
   q.push_back();
   sort(q.begin(),q.end());
   q.erase(unique(q.begin(),q.end()),q.end());
   ;j<n;j++){
      LL  i=lower_bound(q.begin(),q.end(),a[j])-q.begin();
      LL  k=lower_bound(q.begin(),q.end(),b[j])-q.begin();
      //x[j]=i,y[j]=k;
      ll[i]++;
      rr[k]++;
   }
   LL  ans=;
   LL  i=;
   memset(c,,sizeof(c));
   memset(y,,sizeof(y));
   ;j<q.size();j++){
      ) x[j]+=ll[j]-rr[j];
      ];
     // cout<<x[j]<<endl;
   }
   ;j<q.size()-;j++){
     // cout<<x[j]<<" "<<q[j+1]<<" "<<q[j]<<endl;
      y[x[j]]+=q[j+]-q[j];
   }
   ;j<=n;j++){
     cout<<y[j]<<" ";
   }
   cout<<endl;
}

Educational Codeforces Round 46 C - Covered Points Count的更多相关文章

  1. Educational Codeforces Round 46 (Div 2) (A~G)

    目录 Codeforces 1000 A.Codehorses T-shirts B.Light It Up C.Covered Points Count(差分) D.Yet Another Prob ...

  2. 【Codeforces】Educational Codeforces Round 46(Contest 1000)

    题目 传送门:QWQ A:Codehorses T-shirts 题意: 给定一些字符串表示去年和今年的衣服型号大小( XL XXL M...... ),要求用最少的次数把去年的衣服大小改成今年需要的 ...

  3. Educational Codeforces Round 46 (Rated for Div. 2)

    A - Codehorses T-shirts 思路:有相同抵消,没有相同的对答案+1 #include<bits/stdc++.h> #define LL long long #defi ...

  4. Educational Codeforces Round 46 (Rated for Div. 2) C. Covered Points Count

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/C 题意:问你从[l,r]区间的被多少条线覆盖,列出所有答案. 思路:类似括号匹配的 ...

  5. Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses

    Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...

  6. Educational Codeforces Round 46 (Rated for Div. 2) B. Light It Up

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/B 思路:先用两个数组sumon[]和sumoff[]将亮着的灯和灭的灯累计一下. ...

  7. Educational Codeforces Round 46 (Rated for Div. 2) A. Codehorses T-shirts

    Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<b ...

  8. Educational Codeforces Round 64 C. Match Points 【二分思想】

    一 题面 C. Match Points 二 分析 根据题意很容易想到要去找满足条件的数,因为可以打乱输入的顺序,所以很容易想到二分. 但是如果直接对输入的数组进行二分,如输入$a$,直接在数组里二分 ...

  9. Educational Codeforces Round 46 (Rated for Div. 2) D. Yet Another Problem On a Subsequence

    这个题是dp, dp[i]代表以i开始的符合要求的字符串数 j是我们列举出的i之后一个字符串的开始地址,这里的C是组合数 dp[i] += C(j - i - 1, A[i]] )* dp[j]; # ...

随机推荐

  1. 记自己在mybatis中设置jdbcType的一个坑

    项目是用ssm搭建的.主要是为app数据接口.其中有一个需求就app想要查询一段时间内某个用户的测量信息,所以app给我后端传递了3个参数,分别是appuserId(String),startDate ...

  2. Sqlserver 命令行方式修改 用户密码的方法

    1. 之前写了一个 可以使用  ssms 的方式修改密码的情况 2. 还有办法是执行命令 exec sp_password null,'newpassword','sa' # sa 是用户名 newp ...

  3. VUE 处理文本框获焦点高亮

    先贴例子代码  这里又三个div对应的三个input输入框 <!-- 登录的表单 --> <div class="input_group" :class=&quo ...

  4. MHA高可用及读写分离

    一.MHA简介 二.工作流程 三.MHA架构图 四.MHA工具介绍 五.基于GTID的主从复制 六.部署MHA 七.配置VIP漂移 八.配置binlog-server 九.MySQL中间件Atlas

  5. 《笔记》Python itertools的groupby分组数据处理

    今天遇到这么一个需求,需要将这样的数据进行分组处理: [(, ), (, ), (, ), (, ), (, ), (, )] 处理之后我可能需要得到这样的结果: [(, (, , (, , (, ) ...

  6. linux固定IP

    在新安装的Linux系统命令行下, 敲入:ifconfig,显示如下界面. 上面这张图显示网卡没有启动,那么我们敲入代码:ifup eth0启动网卡. 网卡启动后,我们可以看出,IP地址和网关等其他信 ...

  7. 线程同步Volatile与Synchronized(一)

    volatile 一.volatile修饰的变量具有内存可见性 volatile是变量修饰符,其修饰的变量具有内存可见性. 可见性也就是说一旦某个线程修改了该被volatile修饰的变量,它会保证修改 ...

  8. initial

    摘自http://blog.csdn.net/liming0931/article/details/7039680 首先说说结构化过程语句,在verilog中有两种结构化的过程语句:initial语句 ...

  9. Redux 学习(1) ----- Redux介绍

    Redux 有三个基本的原则: 1,单一状态树,redux 只使用一个javascript 对象来保存整个应用的状态. 状态树样式如下: const state = { count: 0 } 2,状态 ...

  10. Spring Boot2.0自定义配置文件使用

    声明: spring boot 1.5 以后,ConfigurationProperties取消locations属性,因此采用PropertySource注解配合使用 根据Spring Boot2. ...