思路: 1. 最终答案不超过能与Nastya“直接交换”的人数. 2. 对于排在j前面的i,如果i和i-j之间(包括j)的每个人都能“直接交换”,j才能前进一步. 实现: #include <bits/stdc++.h> using namespace std; ; int a[N], p[N], cnt[N]; vector<int> v[N]; int main() { int n, m; while (cin >> n >> m) { ; i <…
At the big break Nastya came to the school dining room. There are nn pupils in the school, numbered from 11 to nn. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue…
链接:https://codeforces.com/contest/1136/ A - Nastya Is Reading a Book - [二分] #include<bits/stdc++.h> using namespace std; ; int n,l[maxn],r[maxn],k; int srch(int x) { , R=n; while(L<R) { ; if(l[M]<=x && x<=r[M]) return M; ; ; } retur…
Codeforces Round #546 (Div. 2) 题目链接:https://codeforces.com/contest/1136 A. Nastya Is Reading a Book 题意: 一本书有n个章节,之后给出每个章节所在页数范围,然后有一个人来看书看了k页,问还有多少章节没看. 题解: 水题.模拟一下就好了. #include <bits/stdc++.h> using namespace std; typedef long long ll; ; int n; int…
题目地址:https://codeforces.com/contest/1136 A: Nastya Is Reading a Book 题解:挨个判断即可,水题. 参考代码: #include<bits/stdc++.h> using namespace std; ],r[],k; int main() { scanf("%d",&n); ;i<=n;++i) scanf("%d%d",&l[i],&r[i]); scan…
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=4807 Description The campus of Nanjing University of Science and Technology can be viewed as a graph with N vertexes and M directed edges (vertexes are numbered from 0 to N - 1). Each edge has the s…
BUYING FEED 时间限制:3000 ms | 内存限制:65535 KB 难度:4 描述 Farmer John needs to travel to town to pick up K (1 <= K <= 100)pounds of feed. Driving D miles with K pounds of feed in his truck costs D*K cents. The county feed lot has N (1 <= N<= 100) s…
Lunch Time Time Limit: 2 Seconds Memory Limit: 65536 KB The 999th Zhejiang Provincial Collegiate Programming Contest will be held in Marjar University. The canteen of Marjar University is making preparations for this grand competition. The canteen pr…
题目 两个人从同一个点出发,在一个餐厅中寻找两个相邻的座位,需要是的从出发点到达座位的距离总和最短.题目链接: Have Lunch Together 最短路程,一开始以为要用dijkstra等图算法,发现完全不用,直接用BFS进行搜索,并标记到达每个点的最短距离.一次BFS求出从起始点 到达所有点的最短距离之后,再遍历每个点,判断该点是否是合法的座位(能够从起始点到达,且为座位),然后对每个座位,看它四周的点是否是合法的座位,然 后求出两个合法的座位的最短距离和的最小值. 实现 #in…
B. Lunch Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/B Description The swamp looks like a narrow lane with length n covered by floating leaves sized 1, numbered from 1 to n with a fly sitting on the top of ea…
无限背包dp.. 因为题目中说至少到 H 磅 , 我就直接把 H * 2 了.. -------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i…
2020: [Usaco2010 Jan]Buying Feed, II Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 220 Solved: 162[Submit][Status] Description (buying.pas/buying.in/buying.out 128M 1S) Farmer John needs to travel to town to pick up K (1 <= K <= 100) pounds of feed…
C. Nastya Is Transposing Matrices time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave he…
Jingze is a big figure in California State University for his stubbornness. Because of his new failure in the last CET-4, he has decided not to solve problems with English discription any more. In yesterday‘s warm-up contest,he protested to the organ…
Water Buying time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp wants to cook a soup. To do it, he needs to buy exactly nn liters of water. There are only two types of water bottles i…
Blue skies were finally visible in the capital on Thursday after the region suffered fromseven straight days of intense pollution, sending consumers out in droves to buy pollution masks. in droves:陆陆续续,成群结队 Although Thursday’s weather brought a colle…