Skip to content

Commit 50b1882

Browse files
committed
Added Round 61 form CSacademy
1 parent 1ed2cda commit 50b1882

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

csacademy/Round61/A.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
#define endl '\n'
5+
#define D(x) cout << #x << " = " << (x) << endl;
6+
7+
int main() {
8+
#ifndef ONLINEJUDGE
9+
ios_base::sync_with_stdio(0); cin.tie(0);
10+
#endif
11+
12+
double x;
13+
cin >> x;
14+
15+
cout << (int)((x * 1.8) + 32) << endl;
16+
17+
return 0;
18+
}

csacademy/Round61/B.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+
using namespace std;
3+
4+
#define endl '\n'
5+
#define D(x) cout << #x << " = " << (x) << endl;
6+
7+
int main() {
8+
#ifndef ONLINEJUDGE
9+
ios_base::sync_with_stdio(0); cin.tie(0);
10+
#endif
11+
12+
int n;
13+
cin >> n;
14+
15+
n *= 2;
16+
vector<int> v(n);
17+
for (int i = 0; i < n; ++i) cin >> v[i];
18+
19+
int a = 0;
20+
bool cur = 0;
21+
for (int i = 0; i < n; ++i) {
22+
if (v[i] != cur) a ++;
23+
cur = !cur;
24+
}
25+
26+
27+
a /= 2;
28+
int b = 0;
29+
cur = 1;
30+
for (int i = 0; i < n; ++i) {
31+
if (v[i] != cur) b ++;
32+
cur = !cur;
33+
}
34+
35+
b /= 2;
36+
cout << min(a, b) << endl;
37+
return 0;
38+
}

csacademy/Round61/C.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
#define endl '\n'
5+
#define D(x) cout << #x << " = " << (x) << endl;
6+
7+
int main() {
8+
#ifdef ONLINEJUDGE
9+
ios_base::sync_with_stdio(0); cin.tie(0);
10+
#endif
11+
12+
int n, m;
13+
cin >> n >> m;
14+
15+
int a, b;
16+
vector<int> times(n + 1, 0);
17+
vector<int> l(m), r(m);
18+
for (int i = 0; i < m; ++i) {
19+
cin >> a >> b;
20+
l[i] = a;
21+
r[i] = b;
22+
a --;
23+
times[a] ++;
24+
times[b] --;
25+
}
26+
27+
int zeros = 0;
28+
set<int> uniq;
29+
int acum = 0;
30+
for (int i = 0; i < n; ++i) {
31+
acum += times[i];
32+
if (acum == 1) uniq.insert(i + 1);
33+
if (acum == 0) zeros ++;
34+
}
35+
36+
vector<int> ans(m, 0);
37+
for (int i = 0; i < m && uniq.size() > 0; ++i) {
38+
while (uniq.size() > 0) {
39+
auto lw = uniq.lower_bound(l[i]);
40+
if (lw != uniq.end() && *lw >= l[i] && *lw <= r[i]) {
41+
uniq.erase(lw);
42+
ans[i] ++;
43+
}
44+
else break;
45+
}
46+
}
47+
48+
for (int i = 0; i < m; ++i) cout << ans[i] + zeros << " ";cout << endl;
49+
50+
return 0;
51+
}

0 commit comments

Comments
 (0)