Codeforces 1136 - A/B/C/D/E/F - (Undone)

链接:https://codeforces.com/contest/1136/


A - Nastya Is Reading a Book - [二分]

#include<bits/stdc++.h>
using namespace std;
const int maxn=105;
int n,l[maxn],r[maxn],k;
int srch(int x)
{
    int L=1, R=n;
    while(L<R)
    {
        int M=(L+R)>>1;
        if(l[M]<=x && x<=r[M]) return M;
        else if(x<l[M]) R=M-1;
        else L=M+1;
    }
    return L;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++) cin>>l[i]>>r[i];
    cin>>k;

    cout<<n-srch(k)+1<<endl;
}

B - Nastya Is Playing Computer Games - [思维题]

题解:我只想说,这道思维题有点东西……

AC代码:

#include<bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
    cin>>n>>k;
    cout<<3*n+min(n-k,k-1)<<endl;
}

原文地址:https://www.cnblogs.com/dilthey/p/10540424.html

时间: 2024-11-01 21:54:45

Codeforces 1136 - A/B/C/D/E/F - (Undone)的相关文章

Codeforces 1114 - A/B/C/D/E/F - (Undone)

链接:http://codeforces.com/contest/1114 A - Got Any Grapes? 题意:甲乙丙三个人吃葡萄,总共有三种葡萄:绿葡萄.紫葡萄和黑葡萄,甲乙丙三个人至少要各自吃 $x,y,z$ 个葡萄,又甲只吃绿葡萄,乙不吃黑葡萄,丙三种颜色都吃.现在总共有 $a$ 个绿葡萄.$b$ 个紫葡萄.$c$ 个黑葡萄.要确认这么多葡萄能否使得三个人都满意. 题解:优先满足甲,剩下的绿葡萄加紫葡萄满足乙,最后再剩下的看看能不能满足丙. AC代码: #include<bits

Codeforces 8VC Venture Cup 2016 - Elimination Round F. Group Projects 差分DP*****

F. Group Projects There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent pieces, and then discuss the results together. It takes the i-th stude

Educational Codeforces Round 47 (Rated for Div. 2)F. Dominant Indices 线段树合并

题意:有一棵树,对于每个点求子树中离他深度最多的深度是多少, 题解:线段树合并快如闪电,每个节点开一个权值线段树,递归时合并即可,然后维护区间最多的是哪个权值,到x的深度就是到根的深度减去x到根的深度复杂度O(nlogn) //#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack-protector") //#pragma GCC target("

Educational Codeforces Round 61 (Rated for Div. 2)F(区间DP,思维,枚举)

#include<bits/stdc++.h>typedef long long ll;const int inf=0x3f3f3f3f;using namespace std;char b[507];int dp[507][507];int main(){    memset(dp,0x3f,sizeof(dp));    int n;    scanf("%d",&n);    scanf("%s",b+1);    for(int i=1;

Educational Codeforces Round 81 (Rated for Div. 2)F(线段树)

预处理把左集划分为大小为1~i-1时,把全部元素都移动到右集的代价,记作sum[i]. 然后枚举终态时左集的大小,更新把元素i 留在/移动到 左集的代价. 树状数组/线段树处理区间修改/区间查询 1 #define HAVE_STRUCT_TIMESPEC 2 #include<bits/stdc++.h> 3 using namespace std; 4 #define ll long long 5 const int N=2e5+7; 6 struct Tree{ 7 ll minn,la

Codeforces 474D Flowers

http://codeforces.com/problemset/problem/474/D 思路:F[i]=F[i-1]+(i>=K)F[i-k] 1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 #include<cstring> 5 #include<iostream> 6 const int Mod=1000000007; 7 int K,sum[200005]

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

[ 题解 ] [ 公式 ] F. Teleportation

http://codeforces.com/group/NVaJtLaLjS/contest/238204/problem/F 题意: 农夫弄了个传送点来传送牛粪…… 4个数字,分别代表起点终点和两个传送点的位置. 注意,可以不经过传送门,直接去终点. 示例: Input: 3 10 8 2 Output: 3 水题一道,只要整出3种情况,输出其中的最小值就对了. 分别是:直接去终点:通过传送点x去终点:通过传送点y去终点. 但是当时的我不知道传送点可以不去的… 看好了,这里的代码有重复: 1

codeforeces近日题目小结

upd:2019-12-13 题目源自codeforces的Round_602_div1+2, Round_603_div2, Educational_Round_77 Round_603/F: 考虑一个经典dp状态定义, dp[i][j]代表上面一个树的最后一个被选取的叶节点编号是i 下面的树最后一个被选取的叶节点编号是j且 i != j 那么我们需要考虑第 max(i, j) + 1 个点是选择上下哪棵树的点 这个代价其实就是比较好求的了 Round_602_div1/E: 我直接参考的最短