QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236617 | #7522. Sequence Shift | zhaohaikun | WA | 47ms | 12396kb | C++14 | 1.5kb | 2023-11-04 09:04:52 | 2023-11-04 09:04:53 |
Judging History
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);
sort(a + 1, a + n + 1);
F(i, 0, q) {
if (i) {
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: 100
Accepted
time: 1ms
memory: 7700kb
input:
5 3 1 4 3 2 5 7 5 8 3 2 3 6 4
output:
11 13 16 25
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 7800kb
input:
1 0 103509429 823330096
output:
926839525
result:
ok single line: '926839525'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7696kb
input:
1 1 576560149 691846236 1156187222
output:
1268406385 835582012
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 1ms
memory: 7708kb
input:
1 10 700282491 332230980 90825676 1630266999 644973380 262379760 2122877054 1851957134 1370195232 110993724 1319359505 1883523208
output:
1032513471 1654684398 759763732 888538827 1695749302 1163465539 1425605448 789576931 1397740634 1202288326 1638577353
result:
ok 11 lines
Test #5:
score: -100
Wrong Answer
time: 47ms
memory: 12396kb
input:
1000 100000 438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...
output:
1925225647 1986083253 1967509108 1973351244 1870466316 1946714235 1976394149 1995721753 1946870160 1984280254 1949743439 1955903880 1944520591 1937726835 1993563403 1927000559 1881369267 1979133252 1979156812 1894315082 1878023449 1980597785 1920610605 1898768100 1905728655 1953947075 1892273944 193...
result:
wrong answer 1st lines differ - expected: '1962871590', found: '1925225647'