Codeforces 1136 - A/B/C/D/E - (Done)
链接:https://codeforces.com/contest/1136/
A - Nastya Is Reading a Book - [二分]
#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int n,l[maxn],r[maxn],k;
int srch(int x)
{
int L=, R=n;
while(L<R)
{
int M=(L+R)>>;
if(l[M]<=x && x<=r[M]) return M;
else if(x<l[M]) R=M-;
else L=M+;
}
return L;
}
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); cin>>n;
for(int i=;i<=n;i++) cin>>l[i]>>r[i];
cin>>k; cout<<n-srch(k)+<<endl;
}
B - Nastya Is Playing Computer Games - [思维题]
题解:我只想说,这道思维题有点东西……
AC代码:
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
cin>>n>>k;
cout<<*n+min(n-k,k-)<<endl;
}
C - Nastya Is Transposing Matrices - [有趣的矩阵题]
D - Nastya Is Buying Lunch - [贪心+链表+map]
E - Nastya Hasn't Written a Legend - [线段树+二分]
Codeforces 1136 - A/B/C/D/E - (Done)的更多相关文章
- codeforces#1136 C. Nastya Is Transposing Matrices(找规律)
题意:给出两个n*m的矩阵,每次操作可以让一个正方形矩阵行列交换.问,在无限次操作下,第一个矩阵能否变成第二个矩阵 分析:先把操作限定在2*2的矩阵中.这样对角线上的元素就可以随意交换.也就是说,如果 ...
- codeforces#1136E. Nastya Hasn't Written a Legend(二分+线段树)
题目链接: http://codeforces.com/contest/1136/problem/E 题意: 初始有a数组和k数组 有两种操作,一,求l到r的区间和,二,$a_i\pm x$ 并且会有 ...
- Codeforces Round #546 (Div. 2)
http://codeforces.com/contest/1136 A #include <bits/stdc++.h> using namespace std; ; int N, K; ...
- Codeforces 1136E - Nastya Hasn't Written a Legend - [线段树+二分]
题目链接:https://codeforces.com/problemset/problem/1136/E 题意: 给出一个 $a[1 \sim n]$,以及一个 $k[1 \sim (n-1)]$, ...
- Codeforces 1136D - Nastya Is Buying Lunch - [贪心+链表+map]
题目链接:https://codeforces.com/problemset/problem/1136/D 题意: 给出 $1 \sim n$ 的某个排列 $p$,再给出若干 $(x,y)$ 表示当序 ...
- Codeforces 1136C - Nastya Is Transposing Matrices
题目链接:https://codeforces.com/problemset/problem/1136/C 题意: 给出 $n \times m$ 的矩阵 $A,B$,你可以对其中任意某个 $k \t ...
- Codeforces Round #546 (Div. 2) E 推公式 + 线段树
https://codeforces.com/contest/1136/problem/E 题意 给你一个有n个数字的a数组,一个有n-1个数字的k数组,两种操作: 1.将a[i]+x,假如a[i]+ ...
- Codeforces Round #546 (Div. 2) D 贪心 + 思维
https://codeforces.com/contest/1136/problem/D 贪心 + 思维 题意 你面前有一个队列,加上你有n个人(n<=3e5),有m(m<=个交换法则, ...
- Codeforces Round #546 (Div. 2) 题解
Codeforces Round #546 (Div. 2) 题目链接:https://codeforces.com/contest/1136 A. Nastya Is Reading a Book ...
随机推荐
- 一目了然了解JAVA集合体系
在编程中,常常需要集中存放多个数据.从传统意义上讲,数组是我们的一个很好的选择,前提是我们事先已经明确知道我们将要保存的对象的数量.一旦在数组初始化时指定了这个数组长度,这个数组长度就是不可变的,如果 ...
- 什么是rpc
远程过程调用协议RPC(Remote Procedure Call)—远程过程调用,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议.RPC协议假定某些传输协议的存在,如TC ...
- 超简单的okhttp封装工具类(上)
版权声明:转载请注明出处:http://blog.csdn.net/piaomiao8179 https://blog.csdn.net/piaomiao8179/article/details/ ...
- Git秘钥生成以及Gitlab配置(附以下问题解决方法:Key is invalid Fingerprint cannot be generated)
在进行Git密钥配置时,总是提示: “The form contains the following errors:Key is invalidFingerprint cannot be genera ...
- extjs ajax 同步 及 confirm 确认提示框问题
//上传文件 uploadModel: function() { if(Ext.getCmp('exup').getForm().isValid()) { var ssn = this.upPanel ...
- python3 log 日志记录
在调试的过程中,很多地方需要用到日志 如下 import logging LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s&qu ...
- Xcode 常用代码段
weak_shortcut /** <#注释#> */ @property(nonatomic,weak) <#class#> *<#name#>; copy_sh ...
- MySQL 表中添加 时间戳 字段
场景: 有张表的数据需要用同步工具同步至其他库,需要 update_time 时间戳字段 来做增量同步. 解决方法: alter table quant_stk_calc_d_wxcp add upd ...
- 当我们用自定义的类对象作为key时,我们必须在程序中覆盖HashCode()和equals()。
Key值既然可以作为对象,那么也可以用一个自定义的类.比如: m.put(new sutdent(“Liucy”,30),”boss”) 如果没有语句来判定Student类对象是否相同,则会全部打印出 ...
- 【教程】Win7-64位安装OpenSSL详细过程
1.下载ActivePerl 5.24.0.2400 http://www.activestate.com/activeperl/downloads 图片:ActivePerl-5.24.0.240 ...