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. IdentityServer4【Topic】之登出

    Sign-out 登出 IdentityServer的登出就像删除认证cookie一样简单,但是为了完成一个完整的联合签名,我们必须考虑将用户从客户端应用程序中(甚至可能是上游的Identity提供者 ...

  2. oracle创建表空间、创建用户、授权角色和导入导出用户数据

    使用数据库管理员身份登录 -- log as sysdba sqlplus / as sysdba; 创建临时表空间 -- create temporary tablespace create tem ...

  3. linux关闭触摸板

    关闭触摸板 sudo modprobe -r psmouse 如果打开触摸板就是: sudo modprobe psmouse

  4. js判断数组是否包含某个字符串变量的实例

    最近碰到一个这样的现象,后台返回的数据中,数组里面有一些有变量值,有一些没有变量值. 举个例子,比如后台返回的例子是这样的: var arr=[ { "status":" ...

  5. String类内存空间详解

    java.lang.String类内存问题详解 字符串理解的难点在于其在堆内存空间上的特殊性,字符串String对象在堆内存上有两种空间: 字符串池(String pool):特殊的堆内存,专门存放S ...

  6. windows浏览器访问虚拟机开的rabbitmq服务,无法访问

    根据这个博主的建议 https://blog.csdn.net/csdnliuxin123524/article/details/78207427 换了一个浏览器上火狐浏览器输入“localhost: ...

  7. Storm原理

    zookeeper是对称结构

  8. java学习之—链表(3)

    /** * 使用链表实现队列 * Create by Administrator * 2018/6/19 0019 * 下午 4:37 **/ public class Link { public l ...

  9. mobile adaptor & css media query

    mobile adaptor & css media query 移动端适配 & 媒体查询 http://cssmediaqueries.com/ device-aspect-rati ...

  10. pycharm 安装

    pycharm 1.模板 file->setting->Editor->file and code template->python script->右上方 #!/usr ...