Skip to content

Commit aee4f05

Browse files
committed
The 2025 ICPC Northern Eurasia Finals
1 parent 57c1d0d commit aee4f05

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

QOJ/15899.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @file 15899.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2026-01-20
5+
*
6+
* @copyright Copyright (c) 2026
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#define endl '\n'
14+
15+
#define maxn 500005
16+
17+
int64_t a[maxn], f[maxn];
18+
19+
void solve(void) {
20+
int n;
21+
cin >> n;
22+
for (int i = 1; i <= n; i++) cin >> a[i];
23+
24+
f[1] = a[1], f[n] = 0;
25+
for (int i = 2; i < n; i++) f[i] = a[i] - f[i - 1];
26+
27+
if (n & 1) {
28+
int64_t x = (a[n] - f[n - 1]) / 2;
29+
for (int i = 1; i < n; i++) f[i] += (i & 1) ? -x : +x;
30+
f[n] += x;
31+
32+
int64_t maxv = INT64_MIN, sum = 0;
33+
for (int i = 1; i <= n; i++) maxv = max(maxv, f[i]), sum += f[i];
34+
cout << max(maxv, sum / (n - 1) + (sum % (n - 1) > 0)) << endl;
35+
36+
return;
37+
}
38+
39+
int64_t maxu = INT64_MIN, minu = INT64_MAX, maxd = INT64_MIN, mind = INT64_MAX, sum = 0;
40+
for (int i = 1; i <= n; i += 2) maxd = max(maxd, f[i]), mind = min(mind, f[i]), sum += f[i];
41+
for (int i = 2; i <= n; i += 2) maxu = max(maxu, f[i]), minu = min(minu, f[i]), sum += f[i];
42+
43+
int64_t ans = INT64_MAX;
44+
int64_t X = max(min((maxd - maxu) / 2, mind), -minu);
45+
for (int64_t x = X - 10; x <= X + 10; x++) {
46+
if (mind - x < 0 || minu + x < 0) continue;
47+
int64_t maxv = max(maxd - x, maxu + x);
48+
ans = min(ans, max(maxv, sum / (n - 1) + (sum % (n - 1) > 0)));
49+
}
50+
51+
cout << ans << endl;
52+
53+
return;
54+
}
55+
56+
int main() {
57+
ios::sync_with_stdio(false), cin.tie(nullptr);
58+
59+
int _ = 1;
60+
cin >> _;
61+
while (_--) solve();
62+
63+
return 0;
64+
}

QOJ/15900.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* @file 15900.cpp
3+
* @author Macesuted (i@macesuted.moe)
4+
* @date 2026-01-20
5+
*
6+
* @copyright Copyright (c) 2026
7+
*
8+
*/
9+
10+
#include <bits/stdc++.h>
11+
using namespace std;
12+
13+
#define endl '\n'
14+
15+
multiset<int> split(int n) {
16+
multiset<int> S;
17+
for (int i = 2; i * i <= n; i++)
18+
while (n % i == 0) S.insert(i), n /= i;
19+
if (n > 1) S.insert(n);
20+
return S;
21+
}
22+
23+
void solve(void) {
24+
int w, h, d, n;
25+
cin >> w >> h >> d >> n;
26+
27+
multiset<int> Sw = split(w), Sh = split(h), Sn = split(n);
28+
29+
int wc = 1, hc = 1, dc = 1;
30+
for (auto i = Sn.begin(); i != Sn.end();)
31+
if (Sw.count(*i))
32+
Sw.erase(Sw.find(*i)), wc *= *i, i = Sn.erase(i);
33+
else
34+
i++;
35+
for (auto i = Sn.begin(); i != Sn.end();)
36+
if (Sh.count(*i))
37+
Sh.erase(Sh.find(*i)), hc *= *i, i = Sn.erase(i);
38+
else
39+
i++;
40+
dc = n / wc / hc;
41+
42+
if (d % dc) return cout << -1 << endl, void();
43+
44+
cout << wc - 1 << ' ' << hc - 1 << ' ' << dc - 1 << endl;
45+
46+
return;
47+
}
48+
49+
int main() {
50+
ios::sync_with_stdio(false), cin.tie(nullptr);
51+
52+
int _ = 1;
53+
while (_--) solve();
54+
55+
return 0;
56+
}

0 commit comments

Comments
 (0)