QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236754#7522. Sequence ShiftzhaohaikunWA 1ms7416kbC++142.7kb2023-11-04 10:31:502023-11-04 10:31:51

Judging History

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

  • [2023-11-04 10:31:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7416kb
  • [2023-11-04 10:31:50]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")

// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T& x, T y) { x = max(x, y); }
template <typename T> inline void chkmin(T& x, T y) { x = min(x, y); }
inline char gc() {
	const int BUF = 1e6;
	static char ch[BUF], *l, *r;
	return (l == r && (r = (l = ch) + fread(ch, 1, BUF, stdin), l == r)) ? EOF : *l++;
}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = gc();
	for (; !isdigit(c); c = gc()) if (c == '-') f = -f;
	for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
inline void pc(char c) {
	const int BUF = 1e6;
	static char ch[BUF], *r = ch;
	if (!c || r - ch == BUF) fwrite(ch, 1, r - ch, stdout), r = ch;
	*r++ = c;
}
template <typename T> void write(T x) {
	if (x < 0) { pc('-'); x *= -1; }
	if (x > 9) write(x / 10);
	pc((x % 10) ^ 48);
}
template <typename T> inline void writes(T x) { write(x); pc(32); }
template <typename T> inline void writeln(T x) { write(x); pc('\n'); }
const int N = 2e6 + 10, lim = 1.9995e9;
int n, q, b[N], ans[N];//, aa[N];
int a[N];
// int lst;
// pair <int, int> a[N];
// set <pair <int, int>> s;
vector <int> w;
void work(int x) {
	if (b[x] >= lim / 2) {
		F(i, 1, min(n, x)) {
			// debug << i << " " << x << endl;
			if (a[i] + b[x] >= lim) chkmax(ans[x - i], a[i] + b[x]);
		}
	} else {
		for (int i: w) {
			if (i > x) break;
			// debug << i << " " << x << endl;
			if (a[i] + b[x] >= lim) chkmax(ans[x - i], a[i] + b[x]);
		}
	}
}
void query(int x) {
	if (!ans[x]) {
		F(j, 1, n) chkmax(ans[x], a[j] + b[x + j]);
	}
	writeln(ans[x]);
}
signed main() {
	// debug << (1 - (lim / 2) / 1e9) * 1e6 << endl;
	read(n), read(q);
	F(i, 1, n) {
		// read(a[i].first), a[i].second = i;
		read(a[i]);
		if (a[i] >= lim / 2) w.push_back(i);
	}
	F(i, 1, n) {
		read(b[i]);//, chkmax(lst, a[i].first + b[i]);
		work(i);
	}
	query(0);
	// sort(a + 1, a + n + 1);
	F(i, 1, q) {
		read(b[n + i]);
		b[n + i] ^= ans[i - 1];
		work(n + i);
		query(i);
		// s.erase(make_pair(-b[i], i));
		// s.emplace(-b[n + i], n + i);
		// lst = 0;
		// F(j, 1, min(n, K)) {
		// 	chkmax(lst, a[j].first + b[a[j].second + i]);
		// }
		// auto pos = s.begin();
		// F(j, 1, min(n, K)) {
		// 	chkmax(lst, -pos -> first + aa[pos -> second - i]);
		// 	pos++;
		// }
		// cout << lst << '\n';
	}
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 7416kb

input:

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

output:


result:

wrong answer 1st lines differ - expected: '11', found: ''