Блог пользователя harvey_wzy

Автор harvey_wzy, история, 23 месяца назад, По-английски

Problem: ABC188E

#include <bits/stdc++.h>
using namespace std;

int a[200005], f[200005];
vector<int> pre[200005];

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--, y--;
		pre[y].push_back(x);
	}
	memset(f, 0x3f, sizeof f);
	int ans = -0x3f3f3f3f;
	for (int i = 0; i < n; i++) {
		for (int j : pre[i]) {
			f[i] = min(f[i], f[j]);
			f[i] = min(f[i], a[j]);
		}
		ans = max(ans, a[i] - f[i]);
	}
	printf("%d", ans);
	return 0;
}

I had increase the "infinity" in array f, and I found that when f[i] = 0x3f3f3f3f + 0x3f3f2f2f, it passed , when f[i] = 0x3f3f3f3f + 0x2f2f2f2f, it WA on test #6. I had no idea about it. Could anyone give a test to hack it?

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится