QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236767#7522. Sequence ShiftSSH_automatonRE 0ms0kbC++141.1kb2023-11-04 10:36:142023-11-04 10:36:15

Judging History

你现在查看的是最新测评结果

  • [2023-11-04 10:36:15]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-04 10:36:14]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 2e6 + 5, M = 5307;
const int MAX = 1e9;
int n, q, a[N], b[N], p[N], s[N], len;
int ans[N];

int main() {
	freopen("k.in", "r", stdin);
	freopen("k.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) cin >> b[i];
	int m = min(4000, n);
	int mn = MAX - 1LL * MAX * m / n;
	for (int i = 1; i <= n; ++i) {
		if (a[i] >= mn) p[++len] = i, s[len] = a[i];
	}
	int last = 0;
	for (int i = 1; i <= n; ++i) last = max(last, a[i] + b[i]);
	cout << last << '\n';
	for (int i = 1; i <= n; ++i) {
		if (b[i] < mn) continue;
		for (int j = 1; j <= len; ++j)
			if (i > p[j])
				ans[i - p[j]] = max(ans[i - p[j]], b[i] + s[j]);
	}
	int cnt = 0;
	for (int d = 1; d <= q; ++d) {
		cin >> b[n + d];
		b[n + d] ^= last;
		if (b[n + d] >= mn) {
			++cnt;
			for (int j = 1; j <= len; ++j)
				if (n + d > p[j])
					ans[n + d - p[j]] = max(ans[n + d - p[j]], b[n + d] + s[j]);
		}
		last = ans[d];
		cout << last << '\n';
	}
	cerr << cnt << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:


result: