File tree Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Expand file tree Collapse file tree 3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments