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