Skip to content

Commit 21c306a

Browse files
authored
Merge pull request #509 from xirc/atcoder/abc185
AtCoder/ABC185
2 parents 257443b + 0a33796 commit 21c306a

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

atcoder/abc185/A/main.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int A, B, C, D;
12+
cin >> A >> B >> C >> D;
13+
int N = min({ A, B, C, D });
14+
cout << N << endl;
15+
16+
return 0;
17+
}

atcoder/abc185/B/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 = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int N, M, T;
12+
cin >> N >> M >> T;
13+
14+
bool success = true;
15+
int time = 0;
16+
int remaining = N;
17+
for (int mm = 0; mm < M; ++mm) {
18+
int A, B;
19+
cin >> A >> B;
20+
int consumed = A - time;
21+
remaining -= consumed;
22+
if (remaining <= 0) {
23+
success = false;
24+
break;
25+
}
26+
int charged = B - A;
27+
remaining += charged;
28+
remaining = min(remaining, N);
29+
time = B;
30+
}
31+
int consumed = T - time;
32+
remaining -= consumed;
33+
if (remaining <= 0) success = false;
34+
35+
cout << (success ? "Yes" : "No") << endl;
36+
37+
return 0;
38+
}

atcoder/abc185/C/main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
int L;
12+
cin >> L;
13+
14+
ll ans = 1;
15+
for (int i = 1; i <= 11; ++i) {
16+
ans *= L- i;
17+
ans /= i;
18+
}
19+
cout << ans << endl;
20+
21+
return 0;
22+
}

atcoder/abc185/D/main.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+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int N, M;
8+
vector<int> A;
9+
10+
int solve() {
11+
A.push_back(0);
12+
A.push_back(N + 1);
13+
sort(A.begin(), A.end());
14+
15+
int w = N;
16+
for (int i = 0; i + 1 < A.size(); ++i) {
17+
int space = A[i+1] - A[i] - 1;
18+
if (space > 0) {
19+
w = min(w, space);
20+
}
21+
}
22+
23+
int ans = 0;
24+
for (int i = 0; i + 1 < A.size(); ++i) {
25+
int space = A[i+1] - A[i] - 1;
26+
ans += (space + w - 1) / w;
27+
}
28+
return ans;
29+
}
30+
31+
int main() {
32+
ios_base::sync_with_stdio(false);
33+
cin.tie(0); cout.tie(0);
34+
35+
cin >> N >> M;
36+
A.assign(M, 0);
37+
for (auto &a : A) cin >> a;
38+
cout << solve() << endl;
39+
40+
return 0;
41+
}

0 commit comments

Comments
 (0)