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=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; }
C - Nastya Is Transposing Matrices - [有趣的矩阵题]
D - Nastya Is Buying Lunch - [贪心+链表+map]
E - Nastya Hasn't Written a Legend - [线段树+二分]
转载请注明出处:https://dilthey.cnblogs.com/