Skip to content

Commit 53da2b9

Browse files
idk
1 parent fabb02b commit 53da2b9

21 files changed

+2711
-1
lines changed

Diff for: CSES/1643

17.5 KB
Binary file not shown.

Diff for: CSES/1643.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "bits/stdc++.h"
2+
using namespace std;
3+
#define endl "\n"
4+
#define ll long long int
5+
6+
int main()
7+
{
8+
int n;
9+
cin >> n;
10+
int arr[n];
11+
for(int i = 0; i < n; i++) {
12+
cin >> arr[i];
13+
}
14+
int ans = 0;
15+
int curr = 0;
16+
17+
for(int i = 0; i < n; i++)
18+
{
19+
if(arr[i] >= 0)
20+
{
21+
curr += arr[i];
22+
}
23+
else
24+
{
25+
ans = max(ans, curr);
26+
curr = 0;
27+
}
28+
}
29+
cout << curr << " \n";
30+
ans = max(ans, curr);
31+
32+
cout << ans << endl;
33+
return 0;
34+
}

Diff for: CSES/in

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
10
2+
24 7 -27 17 -67 65 -23 58 85 -39

Diff for: Codechef/2021/Codechef_Starters_11_2021/Positive_Spewing.cpp

+53-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,56 @@ int main()
8484
}
8585

8686
return 0;
87-
}
87+
}
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, m, temp, count = 0, ans = 0, sum = 0;
15+
cin >> n >> m;
16+
vector<string> arr;
17+
string s;
18+
for(i = 0; i < n; i++)
19+
{
20+
cin >> s;
21+
arr.push_back(s);
22+
}
23+
24+
vector<pair<ll, string>> pls;
25+
26+
for(auto e: arr)
27+
{
28+
bool one = false;
29+
count = 0;
30+
ans = 0;
31+
for(auto f: e)
32+
{
33+
if(f == '0')ans++;
34+
}
35+
pls.push_back( {ans, e} );
36+
}
37+
38+
sort(pls.begin(), pls.end(), greater<pair<ll, string>>());
39+
string t = "";
40+
41+
for(auto e: pls)
42+
{
43+
t += e.second;
44+
}
45+
46+
bool one = false;
47+
count = 0;
48+
ans = 0;
49+
for(auto f: t)
50+
{
51+
if(f == '1')
52+
{
53+
one = true;
54+
count++;
55+
}
56+
else
57+
{
58+
if(one)
59+
ans += count;
60+
}
61+
}
62+
63+
cout << ans << endl;
64+
}
65+
66+
return 0;
67+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
15+
cin >> n;
16+
ll arr[n];
17+
18+
for(i = 0; i < n; i++)
19+
{
20+
cin >> arr[i];
21+
}
22+
23+
for(i = 1; i < n; i++)
24+
{
25+
if(arr[i] > arr[i - 1] || arr[i - 1] % arr[i] != 0)
26+
{
27+
sum = 1;
28+
break;
29+
}
30+
}
31+
32+
if(sum || count) cout << -1 << endl;
33+
else
34+
{
35+
for(i = 0; i < n; i++)
36+
{
37+
cout << arr[i] << " ";
38+
}
39+
cout << endl;
40+
}
41+
}
42+
43+
return 0;
44+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
15+
ll a, b, p, q;
16+
cin >> a >> b >> p >> q;
17+
18+
i = a + b;
19+
j = p + q;
20+
21+
if(i % 2 == j % 2)
22+
{
23+
ans = 2;
24+
}
25+
else
26+
{
27+
ans = 1;
28+
}
29+
if(a == p and b == q)
30+
{
31+
ans = 0;
32+
}
33+
cout << ans << endl;
34+
}
35+
36+
return 0;
37+
}
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
15+
cin >> n >> k;
16+
17+
vector<ll> arr;
18+
for(i = 1; i < n / 2; i++)
19+
{
20+
if(i * 2 <= n)
21+
{
22+
ans += 2;
23+
arr.push_back(i);
24+
arr.push_back(i * 2);
25+
}
26+
}
27+
28+
if(ans <= k || ans % k == 0)
29+
{
30+
cout << "Yes" << endl;
31+
for(i = 0; i < k; i++)
32+
{
33+
cout << arr[i] << " ";
34+
}
35+
cout << endl;
36+
}
37+
else
38+
{
39+
cout << "No" << endl;
40+
}
41+
}
42+
43+
return 0;
44+
}
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, ans = 0, sum = 0;
15+
cin >> n;
16+
string s;
17+
cin >> s;
18+
19+
ll one = 0;
20+
ll zero = 0;
21+
22+
for(auto e: s) if(e == '0') zero++;
23+
one = n - zero;
24+
25+
ans = min(one, zero);
26+
27+
if(!ans)
28+
{
29+
sum = 1;
30+
}
31+
32+
if(ans >= 2)
33+
{
34+
temp = one + zero - (2 * ans);
35+
if(temp % 2 == 0) sum = 1;
36+
}
37+
38+
if(!sum) cout << "Alice";
39+
else cout << "Bob";
40+
cout << endl;
41+
}
42+
43+
return 0;
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
15+
cin >> n;
16+
if(n == 2) ans = 2;
17+
else {
18+
ans = n - 1;
19+
}
20+
cout << ans << endl;
21+
}
22+
23+
return 0;
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define endl "\n"
4+
using namespace std;
5+
6+
int main()
7+
{
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(NULL);
10+
ll test;
11+
cin >> test;
12+
while(test--)
13+
{
14+
ll i, j, k, n, temp, count = 0, ans = 0, sum = 0;
15+
cin >> i >> j;
16+
if((i + j) % 2) cout << "Alice";
17+
else cout << "Bob";
18+
cout << endl;
19+
}
20+
21+
return 0;
22+
}

0 commit comments

Comments
 (0)