您的位置:首页 > 其它

Educational Codeforces Round 15

2016-08-04 18:38 363 查看
题目来源:http://www.codeforces.com/contest/702

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: