注意一个词:连续

#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. ios Push证书 转换步骤

    1.将aps_developer_identity.cer转换成aps_developer_identity.pem格式openssl x509 -in aps_developer_identity. ...

  2. NYOJ题目96 n-1位数

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAscAAAJgCAIAAADpjVkvAAAgAElEQVR4nO3du04jS/gv7H0T5FwIsa ...

  3. 前端模板artTemplate,handlerbars的使用心得

    写前端页面肯定离不开模板渲染,就近期项目中用的两个前端模板做一些使用总结,顺便复习一下,也方便后面温故. 1,artTemplate 优点: 1,一般web端用得较多,执行速度通常是 Mustache ...

  4. oracle数据库出现“批处理中出现错误: ORA-00001: 违反唯一约束条件”解决方法

    最近使用oraclede impdp工具全库导入数据库时,在数据库里面使用出现如下情况. SQL state : 违反唯一约束条件 (GDXAORCL.SYS_C0055359) ; nested e ...

  5. Delphi之DLL知识学习2---静态链接和动态链接

    静态连接 静态链接是指Delphi 编译器把要调用的函数和过程编译成可执行代码.函数的代码可存留在应用程序的 .dpr文件或一单元中.当链接用户的应用程序时,这些函数与过程便成为最终的可执行文件的一部 ...

  6. 构造方法 static 块 {}块 执行顺序

    package com.test.innerclass; public class HelloB extends HelloA { public HelloB() { System.out.print ...

  7. .NET yield

    .Net Yield 其实比较简单,手动yield,一学就会. public static class GalaxyClass { public static void ShowGalaxies() ...

  8. angularjs 权威指南 版本 1.2.6

    1 $rootScope  run  : run 方法初始化全局的数据 ,只对全局作用域起作用 如$rootScope <script src="http://apps.bdimg.c ...

  9. 三、spinner

    今天 ,看的和学的都不多,就弄了一个spinner控件而已,下面就记录一下spinner 用法吧 基本上说,使用spinner 有三个步骤 一.在布局文件里面设置spinner 控件,这个不用再多说了 ...

  10. PHPCMS 实现上一篇、下一篇

    方法一:直接调用phpcms系统的函数 <div class="info"> <span>上一篇:<a href="{$previous_p ...