Educational Codeforces Round 15
2016-08-04 18:38
363 查看
题目来源:http://www.codeforces.com/contest/702
A
B
C
A
#include <bits/stdc++.h> #define INF 0x3f3f3f3f #define eps 1e-6 typedef long long LL; const double pi = acos(-1.0); const long long mod = 25 * 1E8; using namespace std; int a[100005]; int dp[100005]; int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ios_base::sync_with_stdio(0);cin.tie(0); int N; cin >> N; for(int i = 1;i <= N;i++) cin >> a[i]; memset(dp,0,sizeof(dp)); dp[1] = 1; int ans = 1; for(int i = 2;i <= N;i++){ if(a[i] > a[i - 1]) dp[i] = dp[i - 1] + 1; else dp[i] = 1; ans = max(ans,dp[i]); } //for(int i = 1;i <= N;i++) //cout << dp[i] << endl; cout << ans << endl; return 0; }
B
#include <bits/stdc++.h> #define _ ios_base::sync_with_stdio(0);cin.tie(0); #define INF 0x3f3f3f3f #define eps 1e-6 typedef long long LL; const double pi = acos(-1.0); const long long mod = 1e9 + 9; using namespace std; LL a[100005]; map <LL,LL> m; int main() { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("int.txt","r",stdin); //freopen("out.txt","w",stdout); int N; cin >> N; m.clear(); for(int i = 0;i < N;i++) { cin >> a[i]; m[a[i]]++; } LL ans = 0; for(int i = 0;i < N;i++){ for(LL j = 1;j < 32;j++){ if( (1 << j) <= a[i] ) continue; ans += m[(1 << j) - a[i]]; if(a[i] == (1 << j) - a[i]) ans--; } } ans /= 2; cout << ans << endl; return 0; }
C
#include <bits/stdc++.h> #define _ ios_base::sync_with_stdio(0);cin.tie(0); #define INF 0x3f3f3f3f #define eps 1e-6 typedef long long LL; const double pi = acos(-1.0); const long long mod = 1e9 + 9; using namespace std; LL a[100005]; LL b[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); //freopen("int.txt","r",stdin); //freopen("out.txt","w",stdout); int N,M; cin >> N >> M; for(int i = 0;i < N;i++) cin >> a[i]; for(int j = 0;j < M;j++) cin >> b[j]; sort(a,a + N); sort(b,b + M); LL l = 0,r = 2000000000; while(l < r) { LL mid = (l + r) / 2; int j = 0; int ok = 0; int i; for(i = 0;i < N;i++) { if(j >= M) { ok = 1; break; } if(fabs(a[i] - b[j]) <= mid) continue; else { j++; i--; } } if(ok) l = mid + 1; else r = mid; } cout << l << endl; return 0; }
相关文章推荐
- Educational Codeforces Round 15 C. Cellular Network(二分)
- 【最长递增子序列+(不下降)二分栈】Educational Codeforces Round 15
- CF Educational Codeforces Round 15(A~D)
- Educational Codeforces Round 15_C. Cellular Network
- Educational Codeforces Round 15
- Educational Codeforces Round 15 Analysis of Pathes in Functional Graph rmq 变形
- Educational Codeforces Round 15_B. Powers of Two
- 【解题报告】Educational Codeforces Round 15
- Codeforces 702 (Educational Codeforces Round 15) A~E
- Educational Codeforces Round 15, problem: (B) Powers of Two
- CF Educational Codeforces Round 15(C)
- Educational Codeforces Round 15_D. Road to Post Office
- Educational Codeforces Round 15
- Educational Codeforces Round 15, problem: (C) Cellular Network
- Educational Codeforces Round 15 A, B , C 暴力 , map , 二分
- Educational Codeforces Round 15 套题
- Educational Codeforces Round 15
- Educational Codeforces Round 15 E. Analysis of Pathes in Functio(每个点走k步会到达哪个点,经过的边中的最小值是多少,经过的边的权值和)
- Educational Codeforces Round 15
- Educational Codeforces Round 15 D. Road to Post Office 数学