Skip to content

AtCoder/ABC001 #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions atcoder/abc001/A/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int H1, H2;
cin >> H1 >> H2;
cout << (H1 - H2) << endl;

return 0;
}
28 changes: 28 additions & 0 deletions atcoder/abc001/B/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int m;
cin >> m;
if (m < 100) {
cout << "00" << endl;
} else if (m <= 5000) {
int vv = m / 100;
cout << setw(2) << setfill('0') << vv << endl;
} else if (m <= 30000) {
int vv = m / 1000 + 50;
cout << vv << endl;
} else if (m <= 70000) {
int vv = (m / 1000 - 30) / 5 + 80;
cout << vv << endl;
} else {
cout << 89 << endl;
}

return 0;
}
46 changes: 46 additions & 0 deletions atcoder/abc001/C/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int power(int dis) {
vector<int> ps = { 24, 154, 334, 544, 794, 1074, 1384, 1714, 2074, 2444, 2844, 3264 };
assert(ps.size() == 12);
for (int i = 0; i < 12; ++i) {
if (dis * 100 <= ps[i] * 60) return i;
}
return 12;
}

string direction(int deg) {
vector<int> ds = {
112, 337, 562, 787, 1012, 1237, 1462, 1687, 1912, 2137, 2362, 2587, 2812, 3037, 3262, 3487
};
vector<string> ss = {
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
};
assert(ds.size() == ss.size());
for (int i = 0; i < ds.size(); ++i) {
if (deg <= ds[i]) return ss[i];
}
return "N";
}

vector<string> solve(int deg, int dis) {
string ans;
int wp = power(dis);
string dir = wp > 0 ? direction(deg) : "C";
return { dir, to_string(wp) };
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

int deg, dis;
cin >> deg >> dis;
auto ans = solve(deg, dis);
cout << ans[0] << " " << ans[1] << endl;

return 0;
}
63 changes: 63 additions & 0 deletions atcoder/abc001/D/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int N;
vector<vector<int>> A;

vector<vector<int>> solve() {
vector<int> ts(24*60+2, 0);

for (int i = 0; i < N; ++i) {
int s = A[i][0], e = A[i][1];
if (s % 5 > 0) s = s - s % 5;
if (e % 5 > 0) e = e - e % 5 + 5;
int ss = (s / 100) * 60 + (s % 100);
int ee = (e / 100) * 60 + (e % 100);
ts[ss] += 1;
ts[ee] -= 1;
}
for (int i = 1; i < ts.size(); ++i) {
ts[i] += ts[i-1];
}

vector<vector<int>> ans;
int s = 0;
bool rain = false;
for (int t = 0; t < ts.size(); ++t) {
if (!rain && ts[t] > 0) {
s = t;
rain = true;
}
if (rain && ts[t] == 0) {
rain = false;
int ss = (s / 60) * 100 + (s % 60);
int ee = (t / 60) * 100 + (t % 60);
ans.push_back({ ss, ee });
}
}
return ans;
}

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);

cin >> N;
for (int i = 0; i < N; ++i) {
string se;
cin >> se;
string s = se.substr(0, 4);
string e = se.substr(5, 4);
A.push_back({ stoi(s), stoi(e) });
}

auto ans = solve();
for (int i = 0; i < ans.size(); ++i) {
cout << setw(4) << setfill('0') << ans[i][0]
<< "-" << setw(4) << setfill('0') << ans[i][1] << endl;
}

return 0;
}