Skip to content

Commit df13f79

Browse files
authored
Merge pull request #306 from xirc/atcoder/abc059
AtCoder/ABC059
2 parents 79fe89d + 12333f8 commit df13f79

File tree

7 files changed

+102
-0
lines changed

7 files changed

+102
-0
lines changed

atcoder/abc059/A/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
string s1, s2, s3;
11+
cin >> s1 >> s2 >> s3;
12+
cout << (char)toupper(s1[0]) << (char)toupper(s2[0]) << (char)toupper(s3[0]) << endl;
13+
14+
return 0;
15+
}

atcoder/abc059/B/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
string A, B;
11+
cin >> A >> B;
12+
int NA = A.size(), NB = B.size();
13+
14+
if (NA > NB || (NA == NB && A > B)) {
15+
cout << "GREATER" << endl;
16+
} else if (NA < NB || (NA == NB && A < B)) {
17+
cout << "LESS" << endl;
18+
} else {
19+
cout << "EQUAL" << endl;
20+
}
21+
22+
return 0;
23+
}

atcoder/abc059/C/main.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N;
7+
vector<int> A;
8+
9+
ll solve(int sign) {
10+
assert(sign == 1 || sign == -1);
11+
ll ans = 0;
12+
ll sum = 0;
13+
for (int i = 0; i < N; ++i) {
14+
sum += A[i];
15+
int c1 = (sign == 1 && sum <= 0) ? -sum + 1 : 0;
16+
int c2 = (sign == -1 && sum >= 0) ? sum + 1 : 0;
17+
assert(c1 >= 0 && c2 >= 0);
18+
sum += c1 + -c2;
19+
sign *= -1;
20+
ans += c1 + c2;
21+
}
22+
return ans;
23+
}
24+
25+
int main() {
26+
ios_base::sync_with_stdio(false);
27+
cin.tie(0); cout.tie(0);
28+
29+
cin >> N;
30+
A.assign(N, 0);
31+
for (int i = 0; i < N; ++i) {
32+
cin >> A[i];
33+
}
34+
35+
cout << min(solve(1), solve(-1)) << endl;
36+
37+
return 0;
38+
}

atcoder/abc059/C/sample1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
0 2

atcoder/abc059/C/sample2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
0 -2

atcoder/abc059/C/sample3.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
3
2+
0 2 -2

atcoder/abc059/D/main.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
string solve(ll X, ll Y) {
7+
ll Z = abs(X - Y);
8+
return Z <= 1 ? "Brown" : "Alice";
9+
}
10+
11+
int main() {
12+
ios_base::sync_with_stdio(false);
13+
cin.tie(0); cout.tie(0);
14+
15+
ll X, Y;
16+
cin >> X >> Y;
17+
cout << solve(X, Y) << endl;
18+
19+
return 0;
20+
}

0 commit comments

Comments
 (0)