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 80eab40

Browse files
committed
「蓝桥」0405 第 28 场 蓝桥入门赛
1 parent 98432fb commit 80eab40

File tree

6 files changed

+233
-0
lines changed

6 files changed

+233
-0
lines changed
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+
typedef long long ll;
5+
6+
void solve() {
7+
cout << "I will fight and win" << endl;
8+
}
9+
10+
signed main() {
11+
ios::sync_with_stdio(false);
12+
cin.tie(nullptr);
13+
14+
int t = 1;
15+
// cin >> t;
16+
while (t--) solve();
17+
return 0;
18+
}
19+
20+
/*
21+
胜利终将属于你【算法赛】
22+
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int a, b, c;
8+
cin >> a >> b >> c;
9+
10+
vector<pair<int, char> > v = {{a, 'l'}, {b, 'q'}, {c, 'b'}};
11+
sort(v.begin(), v.end());
12+
13+
if (v[2].first > v[0].first + v[1].first) {
14+
cout << v[2].second << endl;
15+
} else {
16+
cout << -1 << endl;
17+
}
18+
}
19+
20+
signed main() {
21+
ios::sync_with_stdio(false);
22+
cin.tie(nullptr);
23+
24+
int t = 1;
25+
// cin >> t;
26+
while (t--) solve();
27+
return 0;
28+
}
29+
30+
/*
31+
团队赛【算法赛】
32+
*/
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n, q;
8+
cin >> n >> q;
9+
10+
ll ans = 0;
11+
vector<int> a(n);
12+
for (int i = 0; i < n; ++i) {
13+
cin >> a[i];
14+
ans += a[i];
15+
}
16+
while (q--) {
17+
int l, r;
18+
cin >> l >> r;
19+
int cnt = (r - l + 1) / 2;
20+
ans -= cnt;
21+
if ((r - l + 1) % 2) {
22+
ans += r;
23+
}
24+
}
25+
cout << ans << endl;
26+
}
27+
28+
signed main() {
29+
ios::sync_with_stdio(false);
30+
cin.tie(nullptr);
31+
32+
int t = 1;
33+
// cin >> t;
34+
while (t--) solve();
35+
return 0;
36+
}
37+
38+
/*
39+
蓝桥速算【算法赛】
40+
*/
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n, m;
8+
cin >> n >> m;
9+
10+
vector<int> A(n);
11+
for (auto &i: A) cin >> i;
12+
sort(A.begin(), A.end());
13+
if (A[0] <= m && m <= A[n - 1]) {
14+
cout << "YES" << endl;
15+
} else {
16+
cout << "NO" << endl;
17+
}
18+
}
19+
20+
signed main() {
21+
ios::sync_with_stdio(false);
22+
cin.tie(nullptr);
23+
24+
int t = 1;
25+
cin >> t;
26+
while (t--) solve();
27+
return 0;
28+
}
29+
30+
/*
31+
浓缩咖啡液【算法赛】
32+
*/
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
int n;
8+
cin >> n;
9+
10+
vector<int> t1(n), t2(n);
11+
for (int i = 0; i < n; ++i) {
12+
cin >> t1[i];
13+
}
14+
for (int i = 0; i < n; ++i) {
15+
cin >> t2[i];
16+
}
17+
18+
vector<pair<int, int> > gifts(n);
19+
for (int i = 0; i < n; ++i) {
20+
gifts[i] = {t1[i], t2[i]};
21+
}
22+
23+
vector<pair<int, int> > groupA, groupB;
24+
for (const auto &gift: gifts) {
25+
if (gift.first <= gift.second) {
26+
groupA.push_back(gift);
27+
} else {
28+
groupB.push_back(gift);
29+
}
30+
}
31+
32+
sort(groupA.begin(), groupA.end(),
33+
[](const pair<int, int> &a, const pair<int, int> &b) {
34+
return a.first < b.first;
35+
});
36+
sort(groupB.begin(), groupB.end(),
37+
[](const pair<int, int> &a, const pair<int, int> &b) {
38+
return a.second > b.second;
39+
});
40+
41+
// 合并组A和组B
42+
vector<pair<int, int> > sorted_gifts;
43+
sorted_gifts.insert(sorted_gifts.end(), groupA.begin(), groupA.end());
44+
sorted_gifts.insert(sorted_gifts.end(), groupB.begin(), groupB.end());
45+
46+
// 计算总时间
47+
int sum_t1 = 0;
48+
for (const auto &gift: sorted_gifts) {
49+
sum_t1 += gift.first;
50+
}
51+
52+
int santa_end = 0;
53+
int current_pack_time = 0;
54+
for (const auto &gift: sorted_gifts) {
55+
current_pack_time += gift.first;
56+
int start = max(current_pack_time, santa_end);
57+
santa_end = start + gift.second;
58+
}
59+
60+
int total_time = max(sum_t1, santa_end);
61+
cout << total_time << endl;
62+
}
63+
64+
signed main() {
65+
ios::sync_with_stdio(false);
66+
cin.tie(nullptr);
67+
68+
int t = 1;
69+
// cin >> t;
70+
while (t--) solve();
71+
return 0;
72+
}
73+
74+
/*
75+
破译密码【算法赛】
76+
*/
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
typedef long long ll;
5+
6+
void solve() {
7+
string n;
8+
cin >> n;
9+
set<string> s;
10+
11+
for (int i = 0; i <= n.size(); ++i) {
12+
for (char j = (i ? '0' : '1'); j <= '9'; ++j) {
13+
s.insert(n.substr(0, i) + j + n.substr(i));
14+
}
15+
}
16+
cout << s.size() << endl;
17+
}
18+
19+
signed main() {
20+
ios::sync_with_stdio(false);
21+
cin.tie(nullptr);
22+
23+
int t = 1;
24+
// cin >> t;
25+
while (t--) solve();
26+
return 0;
27+
}
28+
29+
/*
30+
插入数字【算法赛】
31+
*/

0 commit comments

Comments
(0)

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