注意一个词:连续

#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. mybatis配置问题

    //当构造函数有多个参数时,可以使用constructor-arg标签的index属性,index属性的值从0开始. <bean id="sqlSession" class= ...

  2. Swift - 语言指南,来自github学习

    @SwiftLanguage 更新于 2016-6-6,更新内容详见 Issue 55.往期更新回顾详见<收录周报> 这份指南汇集了 Swift 语言主流学习资源,并以开发者的视角整理编排 ...

  3. 清空mysql的历史记录

    # vi ~/.mysql_history show tables; show databases; 清空里面的内容,并不用退出当前shell,就可以清除历史命令!!

  4. HTML+CSS页面滚动效果处理

    HTML+CSS代码如下: <!doctype html> <html> <head> <meta charset="utf-8"> ...

  5. OCJP(1Z0-851) 模拟题分析(九)over

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  6. C#在excel中添加超链接

    1.新建一个项目 2.给项目添加引用:Microsoft Excel 12.0 Object Library (2007版本) using Excel = Microsoft.Office.Inter ...

  7. 运用ASMIOSTAT脚本监控asm disk磁盘性能

    1,脚本作用: 类似于OS的iostat检查磁盘的I/O性能,ASMIOSTAT 脚本用来检查ASM磁盘的性能, 2,下载AMSIOSTAT脚本http://files.cnblogs.com/fil ...

  8. go-martini 简单分析之二

    martini.go 对路由采用正则表达式处理,最终转化成正则表达式. 添加route对应的调用栈 按照生成,验证,添加的步骤 route := newRoute(method, pattern, h ...

  9. Angular JS [Draft]

    AngularJS应用是完全运行在客户端的应用.没有后端的支持,我们只能展示随页面一起加载进来的数据.AngularJS提供了几种方式从服务器端获取数据. $http服务 $http 封装了浏览器原生 ...

  10. SVN-简要说明

    SVN官方推荐在一个版本库的根目录下先建立trunk.branches.tags这三个文件夹,其中trunk是开发主干,存放日常开发的内容:branches存放各分支的内容,比如为不同客户定制的不同版 ...