注意一个词:连续

#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. [转]c++ vector 遍历方式

    挺有趣的,转来记录 随着C++11标准的出现,C++标准添加了许多有用的特性,C++代码的写法也有比较多的变化.   vector是经常要使用到的std组件,对于vector的遍历,本文罗列了若干种写 ...

  2. 验证码的种类与实现 C#封装类 - .NET MVC WEBFORM

    验证码方式 1.随机字母或者数字,纯文本验证码 这种非常容易破解 ,市场上有大量的现成接口或者工具,背景越复杂难度越高. 2.题库验证码 要破解这种验证码,需要人工收集题库才可以破解,可以免疫不是专门 ...

  3. Android浏览本地 API文档 + 解决页面加载慢的问题

    火狐浏览器安装离线浏览插件: 用浏览器打开index.html文件,你会发现加载的很慢,原因你懂的,为此,我们可以通过离线的方式 查看本地API文档,用火狐浏览器  +   Work Offline插 ...

  4. Python win32api提取exe图标icon

    转载地址: http://blog.csdn.net/gumanren/article/details/6129416 代码如下: # -*- coding: utf-8 -*- import sys ...

  5. 【翻译二十三】java-并发程序之随机数和参考资料与问题(本系列完)

    Concurrent Random Numbers In JDK 7, java.util.concurrent includes a convenience class, ThreadLocalRa ...

  6. python中最简单的多进程程序

    学着.. #!/usr/bin/env python # -*- coding: utf-8 -*- # Spawn a Process: Chapter 3: Process Based Paral ...

  7. 数据结构之图 Part2 - 2

    邻接表 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...

  8. AgileEAS.NET SOA 中间件平台5.2版本下载、配置学习(二):配置WinClient分布式运行环境

    一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...

  9. C# 实现单实例程序

    在我们经常使用的软件中,当我们已经打开后,再次打开时,有的软件不会出现两个.例如有道词典,会将上次的界面显示出来,或者提示我们“该程序已经运行...”.我通过一个简单的C# WPF例子来说明. 首先我 ...

  10. hdu 4049 2011北京赛区网络赛J 状压dp ***

    cl少用在for循环里 #include<cstdio> #include<iostream> #include<algorithm> #include<cs ...