注意一个词:连续

#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]的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Educational Codeforces Round 15 C. Cellular Network(二分)

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  4. Educational Codeforces Round 15 C 二分

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  5. Educational Codeforces Round 15 A dp

    A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. 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 ...

  7. 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 ...

  8. Educational Codeforces Round 15 (A - E)

    比赛链接:http://codeforces.com/contest/702 A. Maximum Increase A题求连续最长上升自序列. [暴力题] for一遍,前后比较就行了. #inclu ...

  9. 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 ...

随机推荐

  1. route命令

    Linux系统的route 命令用于显示和操作IP路由表(show / manipulate the IP routing table).要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器, ...

  2. [转]嵌入式SQC文件编译

      Src Url:http://blog.csdn.net/cws1214/article/details/12996351   A.预编译部分  1.预编译DB2篇 1.1 什么是DB2预编译 在 ...

  3. 自己动手编译hadoop-2.5.2源码

    搭建环境:Centos x 6.5  64bit (后来:我才知道原来官网上发布的就是64位的,不过这个对我来说是个学习过程,对以后进行其他平台编译的时候有帮助!) 1.安装JDK 我这里用的是64位 ...

  4. 谈谈我的编程之路---WAMP(三)

    WAMP的一些配置与使用心得(APACHE)说实话,我感觉apache的配置真的还是蛮复杂的,感觉好像又在学一种语言,让我用比较庞大的概念来讲述这些东西,我也没办法做到就以实际应用出发出发,简单的说一 ...

  5. Vs 控件错位 右侧资源管理器文件夹点击也不管用,显示异常

    问题:显卡驱动异常. 缘由:驱动精灵万能显卡安装系统 解决方案:根据笔记本型号去官网下载适配显卡驱动.

  6. 【转载】pyqt QTableWidget的使用

    转载地址: http://blog.sina.com.cn/s/blog_9b78c91101019sgi.html QTableWidget是QT程序中常用的显示数据表格的空间,很类似于VC.C#中 ...

  7. poj 1182:食物链(种类并查集,食物链问题)

    食物链 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 44168   Accepted: 12878 Description ...

  8. tkprof工具详解二(一些实例)

    TKPROF是一个可执行文件,自带在Oracle Server软件中,无需额外的安装. 该工具文件可以用来解析ORACLE的SQL TRACE(10046) 以便生成更可读的内容.  实际上tkpro ...

  9. javascript、正则的验证

    js验证.手机.固话.邮箱.身份证.网址.日期等 Verification.js文件 /* * 手机号码格式 * 只允许以13.15.18开头的号码 * 如:13012345678.159292243 ...

  10. 网站Session 处理方式

    分布式session有以下几种方案: 1. 基于nfs(net filesystem)的session共享 将共享服务器目录mount各服务器的本地session目录,session读写受共享服务器i ...