Codeforces Round #546 (Div. 2)
Posted zlrrrr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #546 (Div. 2)相关的知识,希望对你有一定的参考价值。
http://codeforces.com/contest/1136
A
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; int N, K; struct Node { int L; int R; }node[maxn]; int main() { scanf("%d", &N); for(int i = 1; i <= N; i ++) scanf("%d%d", &node[i].L, &node[i].R); scanf("%d", &K); int cnt = 0; for(int i = 1; i <= N; i ++) { if(node[i].R >= K) cnt ++; else continue; } printf("%d ", cnt); return 0; }
B
#include <bits/stdc++.h> using namespace std; int N, K; int main() { scanf("%d%d", &N, &K); int ans = 0; ans = 3 * N + min(K - 1, N - K); printf("%d ", ans); return 0; }
C
D
#include <bits/stdc++.h> using namespace std; const int maxn = 3e5 + 10; vector<int> v[maxn]; int N, M; int num[maxn], ans[maxn]; int main() { scanf("%d%d", &N, &M); for(int i = 1; i <= N; i ++) scanf("%d", &num[i]); while(M --) { int uu, vv; scanf("%d%d", &uu, &vv); v[vv].push_back(uu); } for(int i = 0; i < v[num[N]].size(); i ++) ans[v[num[N]][i]] ++; int cnt = 0; for(int i = N - 1; i >= 1; i --) { if(ans[num[i]] == N - i - cnt) cnt ++; else { for(int j = 0; j < v[num[i]].size(); j ++) ans[v[num[i]][j]] ++; } } printf("%d ", cnt); return 0; }
很久没更新了 最近和队友训练准备这样那样的比赛 写完题好像也没贴 哭唧唧 会尽快把之前做的题总结一下发上来的 养肥我的 Be 客
FH
以上是关于Codeforces Round #546 (Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #546 (Div. 2) D 贪心 + 思维
Codeforces Round #546 (Div. 2)-D - Nastya Is Buying Lunch
Codeforces Round #546 (Div. 2) D. Nastya Is Buying Lunch
Codeforces-Round#546(Div.2)-D-Nastya Is Buying Lunch
Nastya Hasn't Written a Legend(Codeforces Round #546 (Div. 2)E+线段树)