Heim  >  Artikel  >  Datenbank  >  Codeforces Round #264 (Div. 2)

Codeforces Round #264 (Div. 2)

WBOY
WBOYOriginal
2016-06-07 15:44:181072Durchsuche

Codeforces Round #264 (Div. 2) 题目链接 A:注意特判正好的情况,其他就一个个去判断记录最大即可 B:扫一遍,不够的用钱去填即可,把多余能量记录下来 C:把主副对角线处理出来,然后黑白只能各选一个最大的放即可 D:转化为DAG最长路问题,每个数字记录

Codeforces Round #264 (Div. 2)

题目链接

A:注意特判正好的情况,其他就一个个去判断记录最大值即可

B:扫一遍,不够的用钱去填即可,把多余能量记录下来

C:把主副对角线处理出来,然后黑格白格只能各选一个最大的放即可

D:转化为DAG最长路问题,每个数字记录下在每个序列的位置,如果一个数字能放上去,那么肯定是每个序列上的数字都是在之前最末尾数字的后面

E:大力出奇迹,预处理出树,然后每次查询从当前位置一直往上找到一个符合的即可,如果没有符合的就是-1

代码:

A:

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n, s;

int main() {
	scanf("%d%d", &n, &s);
	int x, y;
	int flag = 1;
	int ans = 0;
	for (int i = 0; i <br>
B:
<pre class="brush:php;toolbar:false">#include <cstdio>
#include <cstring>

const int N = 100005;
typedef long long ll;

int n;
ll h[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i  h[i - 1]) {
			ll need = h[i] - h[i - 1];
			if (now >= need) {
				now -= need;
			} else {
				ans += need - now;
				now = 0;
			}
		} else {
			now += h[i - 1] - h[i];
		}
	}
	printf("%lld\n", ans);
	return 0;
}</cstring></cstdio>

C:
#include <cstdio>
#include <cstring>

const int N = 2005;

typedef long long ll;

int n;
ll g[N][N], zhu[N + N], fu[N + N];

int main() {
	scanf("%d", &n);
	for (int i = 0; i <br>
D:
<pre class="brush:php;toolbar:false">#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1005;

struct Num {
	int v[10], la;
} num[N];

bool cmp(Num a, Num b) {
	return a.la <br>
E:
<pre class="brush:php;toolbar:false">#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

const int N = 100005;

int n, q, val[N], f[N];
vector<int> g[N];

void dfs(int u, int fa) {
	f[u] = fa;
	for (int i = 0; i  1) return u;
		u = f[u];
	}
	return -1;
}

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i <br>
<br>



</int></vector></cstring></cstdio>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn