Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5a2ac34

Browse files
committed
Codeforces Round #318
1 parent b14356a commit 5a2ac34

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

‎Codeforces/Codeforces Round #318/a.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int N;
5+
int a[1 << 17];
6+
7+
int main() {
8+
ios_base::sync_with_stdio(0);
9+
cin.tie(0);
10+
11+
cin >> N;
12+
for (int i = 0; i < N; ++i) {
13+
cin >> a[i];
14+
while (a[i] % 2 == 0) a[i] /= 2;
15+
while (a[i] % 3 == 0) a[i] /= 3;
16+
}
17+
18+
for (int i = 0; i < N; ++i)
19+
if (a[i] != a[0]) {
20+
cout << "No" << endl;
21+
return 0;
22+
}
23+
24+
cout << "Yes" << endl;
25+
26+
return 0;
27+
}

‎Codeforces/Codeforces Round #318/b.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
const int
5+
MAXN = 1 << 17;
6+
7+
int N;
8+
int h[MAXN];
9+
int L[MAXN];
10+
int R[MAXN];
11+
int ans;
12+
13+
int main() {
14+
ios_base::sync_with_stdio(0);
15+
cin.tie(0);
16+
17+
cin >> N;
18+
for (int i = 1; i <= N; ++i)
19+
cin >> h[i];
20+
21+
int best = 0;
22+
for (int i = 1; i <= N; ++i) {
23+
L[i] = i + best;
24+
best = min(best, h[i] - i);
25+
}
26+
27+
best = N+1;
28+
for (int i = N; i >= 1; --i) {
29+
R[i] = best - i;
30+
best = min(best, h[i] + i);
31+
}
32+
33+
for (int i = 1; i <= N; ++i) {
34+
int t = min(h[i], min(L[i], R[i]));
35+
ans = max(ans, t);
36+
}
37+
38+
cout << ans << endl;
39+
40+
return 0;
41+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /