Educational Codeforces Round 15 [111110]

注意一个词:连续
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
long long a[];
int main()
{
//freopen("input.txt","r",stdin);
int n;
scanf("%d", &n);
for (int i = ; i <= n; i++)
scanf("%I64d", &a[i]);
int ans = ;
int i = , tmp = ;
while (i <= n)
{
if (a[i - ] < a[i]) tmp++;
else
{
if (tmp > ans) ans = tmp;
tmp = ;
}
i++;
}
if (tmp > ans) ans = tmp;
printf("%d\n", ans);
//fclose(stdin);
return ;
}

枚举每个可能的和,用map记下每种值有多少个,n个数过一遍,每次加上和减去当前值的差的值的个数。当当前值本身是2的幂时要额外减一。
int和longlong一起运算时最好把int弄成longlong
#include <iostream>
#include <map>
using namespace std; map<long long, int> e;
long long a[]; int main()
{
int n;
cin >> n;
for (int i = ; i <= n; i++)
cin >> a[i];
e.clear();
for (int i = ; i <= n; i++)
e[a[i]]++;
long long sum = ;
for (int i = ; i <= n; i++)
sum += a[i];
long long ans = ;
for (int i = ; i <= n; i++)
{
long long tmp = ;
for (long long j = ; j <= sum; j <<= )
{
if (j <= a[i]) continue;
long long f = j - a[i];
tmp += e[f];
if (f == a[i]) tmp--;
}
ans += tmp;
}
cout << ans / << endl;
//system("pause");
return ;
}

用二分法找到每个点最近的塔的距离,所有距离中最大的就是最小的满足条件的r。
#include <iostream>
#include <map>
using namespace std; __int64 a[], b[]; int main()
{
int n, m;
cin >> n >> m; for(int i = ; i <= n; i++)
cin >> a[i]; for(int i = ; i <= m; i++)
cin >> b[i]; __int64 MAX = ; for(int i = ; i <= n; i++)
{
__int64 tmp = 1e15; if(a[i] <= b[]) tmp = b[] - a[i];
else if(b[m] <= a[i]) tmp = a[i] - b[m];
else
{
int l = , r = m, mid; while()
{
mid = (l + r) >> ; if(a[i] < b[mid]) r = mid;
else l = mid; if(l == r || l + == r) break;
} tmp = a[i] - b[l]; if(b[r] - a[i] < tmp) tmp = b[r] - a[i];
} if(tmp > MAX) MAX = tmp;
} cout << MAX << endl;
//system("pause");
return ;
}

跟VJ上的守望者的逃离差不多。
#include <iostream>
#include <map>
using namespace std; int main()
{
long long d, k, a, b, t;
cin >> d >> k >> a >> b >> t; if(d <= k)
{
cout << d*a << endl;
return ;
} long long ans = k * a;
d -= k;
long long p = d / k; if(t + k * a < k * b) ans += (t + k * a) * p;
else ans += k * b * p; d %= k; if(t + d * a < d * b) ans += (t + d * a);
else ans += d * b; cout << ans << endl;
//system("pause");
return ;
}

这题只说一句:快速幂。
>技不如人,甘拜下风。
>相当精彩的比赛。
#include <iostream>
#include <string>
#include <map>
using namespace std;
int f[][], fa[];
long long SUM[][], MIN[][], w[];
long long Asum[], Amin[];
int Ap[];
int main()
{
long long n, k;
cin >> n >> k;
for (int i = ; i < n; i++)
cin >> fa[i];
for (int i = ; i < n; i++)
cin >> w[i];
for (int i = ; i < n; i++)
{
f[i][] = fa[i];
SUM[i][] = w[i];
MIN[i][] = w[i];
}
for (int i = ; i <= ; i++)
{
for (int j = ; j < n; j++)
{
int x = f[j][i - ];
f[j][i] = f[x][i - ];
SUM[j][i] = SUM[j][i - ] + SUM[x][i - ];
MIN[j][i] = MIN[j][i - ];
if (MIN[j][i - ] > MIN[x][i - ]) MIN[j][i] = MIN[x][i - ];
}
}
memset(Asum, , sizeof(Asum));
for (int i = ; i < n; i++)
{
Amin[i] = 1e15;
Ap[i] = i;
}
for (int i = ; i <= ; i++)
{
if ((k & ((long long) << i)) == ) continue;
for (int j = ; j < n; j++)
{
int x = Ap[j];
Asum[j] += SUM[x][i];
if (Amin[j] > MIN[x][i]) Amin[j] = MIN[x][i];
Ap[j] = f[x][i];
}
}
for (int i = ; i < n; i++)
cout << Asum[i] << " " << Amin[i] << endl;
//system("pause");
return ;
}
Educational Codeforces Round 15 [111110]的更多相关文章
- Codeforces Educational Codeforces Round 15 C. Cellular Network
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 15 A. Maximum Increase
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C. Cellular Network(二分)
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 C 二分
C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 15 A dp
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph
E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...
- Codeforces Educational Codeforces Round 15 D. Road to Post Office
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Educational Codeforces Round 15 (A - E)
比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #inclu ...
- Educational Codeforces Round 15 A, B , C 暴力 , map , 二分
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- LeetCode : 93. Restore IP Addresses
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABZ4AAAHUCAYAAAC6Zj2HAAAMFGlDQ1BJQ0MgUHJvZmlsZQAASImVlw
- 5.1 stack,queue以及priority_queue
*:stack 使用要包含头文件stack,栈是一种先进后出的元素序列,删除和访问只能对栈顶的元素(最后一个添加的元素)进行,并且添加元素只能添加到栈顶.栈内的元素不能访问,要想访问先要删除其上方的所 ...
- sp_who使用
[SQL Server] sp_who, sp_who2和sp_who3 sp_who可以返回如下信息: (可选参数LoginName, 或active代表活动会话数)Spid (系 ...
- Dubbo应用与异常记录
结合项目里使用暴露出的问题,对并发较多的核心业务或者对请求失败等敏感的业务场景不太建议使用Dubbo, 如电商的购买等行为,使用Dubbo就必须阅读源码,熟悉相关机制,或者直接自己造轮子. >& ...
- 手机的ROM,RAM是各自存放什么?所谓“运行内存”和“机身内存”究竟有什么区别?
手机的内存分为运行内存(RAM)和非运行内存(也叫机身内存.储存空间.ROM) 1.手机的内存,分为存储内存和运行内存,相当于电脑的硬盘和内存条.2.存储内存分为机身内存和存储卡.3.rom是存储内存 ...
- Delphi之DLL知识学习3---为什么要使用DLL
使用DLL有若干理由,其中有一些前面提到过的.大体说来,使用动态链接库可以共享代码.系统资源,可以隐藏实现的代码或底层的系统例程.设计自定义控件 一.共享代码.资源和数据 前面已经提到,共享代码是创建 ...
- 【翻译七】java-同步
Synchronization Threads communicate primarily by sharing access to fields and the objects reference ...
- Oracle【IT实验室】数据库备份与恢复之六:LogMiner
6.1 LogMiner 的用途 Oracle LogMiner 是Oracle公司从产品8i以后提供的一个实际非常有用的分析工具,使用该工具可以轻松获得 Oracle 重作日志文件(归档日志文件) ...
- java + jni + mingw实例开发(基于命令行窗口模式)
java+ jni + mingw 参考网址: http://wenku.baidu.com/link?url=9aQ88d2ieO7IgKLlNhJi5d3mb3xwzbezLPzSIX3ixz4_ ...
- POJ 1625 Censored!(AC自动机+DP+高精度)
Censored! Time Limit: 5000MS Memory Limit: 10000K Total Submissions: 6956 Accepted: 1887 Descrip ...