QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236621#7522. Sequence ShiftzhaohaikunWA 1ms7700kbC++141.5kb2023-11-04 09:06:012023-11-04 09:06:03

Judging History

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

  • [2023-11-04 09:06:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7700kb
  • [2023-11-04 09:06:01]
  • 提交

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); }
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 2e6 + 10;
int n, q, b[N], lst, aa[N];
pair <int, int> a[N];
set <pair <int, int>> s;
signed main() {
	read(n), read(q);
	F(i, 1, n) read(aa[i]), a[i].first = aa[i], a[i].second = i;
	F(i, 1, n) read(b[i]), s.emplace(-b[i], i), chkmax(lst, aa[i] + b[i]);
	sort(a + 1, a + n + 1);
	F(i, 1, q) {
		read(b[n + i]);
		b[n + i] ^= lst;
		s.erase(make_pair(-b[i], i));
		s.emplace(b[n + i], n + i);
		lst = 0;
		F(j, 1, min(n, 20)) {
			chkmax(lst, a[j].first + b[a[j].second + i]);
		}
		auto pos = s.begin();
		F(j, 1, min(n, 20)) {
			// debug << pos -> first << " " << pos -> second << endl;
			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: 7700kb

input:

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

output:

13
16
25

result:

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