Skip to content

Commit d8e438e

Browse files
committed
cf
1 parent cc6675b commit d8e438e

File tree

4 files changed

+146
-0
lines changed

4 files changed

+146
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
int solve()
10+
{
11+
long long x,y,z;
12+
cin >> x >> y >> z;
13+
if(x%z+y%z<z)
14+
cout<<(x+y)/z<<" "<<0<<endl;
15+
else
16+
cout<<(x+y)/z<<" "<<min(z-x%z,z-y%z)<<endl;
17+
return 0;
18+
}
19+
int main()
20+
{
21+
int testCase = 1;
22+
while (testCase--)
23+
{
24+
solve();
25+
}
26+
return 0;
27+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
int solve()
10+
{
11+
int n;
12+
cin >> n;
13+
vector<int> a(n), odd, even;
14+
for (int i = 0; i < n; i++)
15+
{
16+
cin >> a[i];
17+
(a[i] % 2 ? odd : even).push_back(i);
18+
}
19+
vector<int> temp;
20+
for (int i = 0; i < 3 && i < odd.size(); i++)
21+
{
22+
temp.push_back(odd[i]);
23+
}
24+
for (int i = 0; i < 3 && i < even.size(); i++)
25+
{
26+
temp.push_back(even[i]);
27+
}
28+
for (int i : temp)
29+
{
30+
for (int j : temp)
31+
{
32+
for (int k : temp)
33+
{
34+
if (i != j && j != k && k != i && (a[i] + a[j] + a[k]) % 2)
35+
{
36+
cout << "YES\n";
37+
cout << i + 1 << " " << j + 1 << " " << k + 1 << "\n";
38+
return 0;
39+
}
40+
}
41+
}
42+
}
43+
cout << "NO\n";
44+
return 0;
45+
}
46+
int main()
47+
{
48+
int testCase = 1;
49+
cin >> testCase;
50+
while (testCase--)
51+
{
52+
solve();
53+
}
54+
return 0;
55+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
10+
int solve(){
11+
int n,ones=0;
12+
cin>>n;
13+
for (int i = 0; i < n; i++)
14+
{
15+
int x;
16+
cin>>x;
17+
if (x == 1)
18+
ones++;
19+
}
20+
printf("%d\n", n - ones / 2);
21+
return 0;
22+
}
23+
int main()
24+
{
25+
int testCase=1;
26+
cin>>testCase;
27+
while(testCase--){
28+
solve();
29+
}
30+
return 0;
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
using namespace std;
7+
typedef long long ll;
8+
9+
int solve()
10+
{
11+
int a, b, c, d;
12+
cin >> a >> b >> c >> d;
13+
if (a == 0)
14+
{
15+
cout << 1 << endl;
16+
return 0;
17+
}
18+
int ans = a;
19+
ans += 2 * min(b, c);
20+
ans += min(a + 1, abs(c - b) + d);
21+
cout << ans << endl;
22+
return 0;
23+
}
24+
int main()
25+
{
26+
int testCase = 1;
27+
cin >> testCase;
28+
while (testCase--)
29+
{
30+
solve();
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)