Skip to content

Commit 04352c3

Browse files
authored
Merge pull request #313 from xirc/atcoder/abc001
AtCoder/ABC001
2 parents 97823b6 + 6e754bb commit 04352c3

File tree

4 files changed

+152
-0
lines changed

4 files changed

+152
-0
lines changed

atcoder/abc001/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+
int H1, H2;
11+
cin >> H1 >> H2;
12+
cout << (H1 - H2) << endl;
13+
14+
return 0;
15+
}

atcoder/abc001/B/main.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
int m;
11+
cin >> m;
12+
if (m < 100) {
13+
cout << "00" << endl;
14+
} else if (m <= 5000) {
15+
int vv = m / 100;
16+
cout << setw(2) << setfill('0') << vv << endl;
17+
} else if (m <= 30000) {
18+
int vv = m / 1000 + 50;
19+
cout << vv << endl;
20+
} else if (m <= 70000) {
21+
int vv = (m / 1000 - 30) / 5 + 80;
22+
cout << vv << endl;
23+
} else {
24+
cout << 89 << endl;
25+
}
26+
27+
return 0;
28+
}

atcoder/abc001/C/main.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int power(int dis) {
7+
vector<int> ps = { 24, 154, 334, 544, 794, 1074, 1384, 1714, 2074, 2444, 2844, 3264 };
8+
assert(ps.size() == 12);
9+
for (int i = 0; i < 12; ++i) {
10+
if (dis * 100 <= ps[i] * 60) return i;
11+
}
12+
return 12;
13+
}
14+
15+
string direction(int deg) {
16+
vector<int> ds = {
17+
112, 337, 562, 787, 1012, 1237, 1462, 1687, 1912, 2137, 2362, 2587, 2812, 3037, 3262, 3487
18+
};
19+
vector<string> ss = {
20+
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
21+
};
22+
assert(ds.size() == ss.size());
23+
for (int i = 0; i < ds.size(); ++i) {
24+
if (deg <= ds[i]) return ss[i];
25+
}
26+
return "N";
27+
}
28+
29+
vector<string> solve(int deg, int dis) {
30+
string ans;
31+
int wp = power(dis);
32+
string dir = wp > 0 ? direction(deg) : "C";
33+
return { dir, to_string(wp) };
34+
}
35+
36+
int main() {
37+
ios_base::sync_with_stdio(false);
38+
cin.tie(0); cout.tie(0);
39+
40+
int deg, dis;
41+
cin >> deg >> dis;
42+
auto ans = solve(deg, dis);
43+
cout << ans[0] << " " << ans[1] << endl;
44+
45+
return 0;
46+
}

atcoder/abc001/D/main.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int N;
7+
vector<vector<int>> A;
8+
9+
vector<vector<int>> solve() {
10+
vector<int> ts(24*60+2, 0);
11+
12+
for (int i = 0; i < N; ++i) {
13+
int s = A[i][0], e = A[i][1];
14+
if (s % 5 > 0) s = s - s % 5;
15+
if (e % 5 > 0) e = e - e % 5 + 5;
16+
int ss = (s / 100) * 60 + (s % 100);
17+
int ee = (e / 100) * 60 + (e % 100);
18+
ts[ss] += 1;
19+
ts[ee] -= 1;
20+
}
21+
for (int i = 1; i < ts.size(); ++i) {
22+
ts[i] += ts[i-1];
23+
}
24+
25+
vector<vector<int>> ans;
26+
int s = 0;
27+
bool rain = false;
28+
for (int t = 0; t < ts.size(); ++t) {
29+
if (!rain && ts[t] > 0) {
30+
s = t;
31+
rain = true;
32+
}
33+
if (rain && ts[t] == 0) {
34+
rain = false;
35+
int ss = (s / 60) * 100 + (s % 60);
36+
int ee = (t / 60) * 100 + (t % 60);
37+
ans.push_back({ ss, ee });
38+
}
39+
}
40+
return ans;
41+
}
42+
43+
int main() {
44+
ios_base::sync_with_stdio(false);
45+
cin.tie(0); cout.tie(0);
46+
47+
cin >> N;
48+
for (int i = 0; i < N; ++i) {
49+
string se;
50+
cin >> se;
51+
string s = se.substr(0, 4);
52+
string e = se.substr(5, 4);
53+
A.push_back({ stoi(s), stoi(e) });
54+
}
55+
56+
auto ans = solve();
57+
for (int i = 0; i < ans.size(); ++i) {
58+
cout << setw(4) << setfill('0') << ans[i][0]
59+
<< "-" << setw(4) << setfill('0') << ans[i][1] << endl;
60+
}
61+
62+
return 0;
63+
}

0 commit comments

Comments
 (0)