File tree Expand file tree Collapse file tree 4 files changed +198
-0
lines changed
Codeforces/After Placement Expand file tree Collapse file tree 4 files changed +198
-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
+
10
+ int solve (){
11
+ int n, l, r;
12
+ cin >> n >> l >> r;
13
+ int mini = 0 , maxo = 0 ;
14
+ int t = 1 ;
15
+ for (int x = 1 ; x <= l; x++){
16
+ mini += t, t *= 2 ;
17
+ }
18
+ mini += (n - l);
19
+ t=1 ;
20
+ for (int x = 1 ; x <= r; x++){
21
+ maxo += t, t *= 2 ;
22
+ }
23
+ maxo += (n - r) * t / 2 ;
24
+ cout << mini << " " << maxo << endl;
25
+ return 0 ;
26
+ }
27
+ int main ()
28
+ {
29
+ int testCase=1 ;
30
+ while (testCase--){
31
+ solve ();
32
+ }
33
+ return 0 ;
34
+ }
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
+ long long a,b,n,m;
12
+ cin>>a>>b>>n>>m;
13
+ if (n<=m){
14
+ cout<<n*min (a,b)<<endl;
15
+ return 0 ;
16
+ }
17
+
18
+ if ((m*a)<=(m+1 )*b){
19
+ long long temp1=n/(m+1 );
20
+ long long temp2=n%(m+1 );
21
+ long long temp3=temp1*m*a;
22
+ // cout<<"temp1 is "<<temp1<<endl;
23
+ // cout<<"temp2 is "<<temp2<<endl;
24
+ // cout<<"temp3 is "<<temp3<<endl;
25
+ temp3+=temp2*min (a,b);
26
+ cout<<temp3<<endl;
27
+ }
28
+ else {
29
+ cout<<n*b<<endl;
30
+ }
31
+ return 0 ;
32
+ }
33
+ int main ()
34
+ {
35
+ int testCase=1 ;
36
+ cin>>testCase;
37
+ while (testCase--){
38
+ solve ();
39
+ }
40
+ return 0 ;
41
+ }
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,m;
12
+ cin>>n>>m;
13
+ string s1=" " , s2=" " ;
14
+ string temp=" " ;
15
+ bool flag=true ;
16
+ cin>>s1>>s2;
17
+ for (int i=0 ;i+1 <n;i++){
18
+ if (s1[i]==s1[i+1 ]){
19
+ temp=s1.substr (i+1 ,n);
20
+ // cout<<"temp is "<<temp<<endl;
21
+ flag=false ;
22
+ break ;
23
+ }
24
+ }
25
+ if (!flag){
26
+ reverse (temp.begin (),temp.end ());
27
+ s2+=temp;
28
+ for (int i=0 ;i+1 <s2.size ();i++){
29
+ if (s2[i]==s2[i+1 ]){
30
+ cout<<" NO" <<endl;
31
+ return 0 ;
32
+ }
33
+ }
34
+ }
35
+ temp=" " ;
36
+ flag=true ;
37
+ for (int i=0 ;i+1 <m;i++){
38
+ if (s2[i]==s2[i+1 ]){
39
+ temp=s2.substr (i+1 ,m);
40
+ flag=false ;
41
+ break ;
42
+ }
43
+ }
44
+ if (!flag){
45
+ reverse (temp.begin (),temp.end ());
46
+ s1+=temp;
47
+ for (int i=0 ;i+1 <s1.size ();i++){
48
+ if (s1[i]==s1[i+1 ]){
49
+ cout<<" NO" <<endl;
50
+ return 0 ;
51
+ }
52
+ }
53
+ }
54
+ cout<<" YES" <<endl;
55
+ return 0 ;
56
+ }
57
+ int main ()
58
+ {
59
+ int testCase=1 ;
60
+ cin>>testCase;
61
+ while (testCase--){
62
+ solve ();
63
+ }
64
+ return 0 ;
65
+ }
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,k;
12
+ cin>>n>>k;
13
+ vector<pair<int ,int >> v (n);
14
+ map<int ,int > m;
15
+ int countOfMaxo=0 ;
16
+ for (int i=0 ;i<n;i++){
17
+ cin>>v[i].first >>v[i].second ;
18
+ for (int j=v[i].first ;j<=v[i].second ;j++){
19
+ m[j]++;
20
+ }
21
+ }
22
+ // cout<<"k frequency is "<<m[k]<<endl;
23
+ bool flag=true ;
24
+ for (int i=1 ;i<=50 ;i++){
25
+ if (i!=k && m[i]>=m[k]){
26
+ flag=false ;
27
+ int count=0 ;
28
+ for (auto x:v){
29
+ if (x.second >=i && x.first <=i && (x.second <k || x.first >k)){
30
+ count++;
31
+ }
32
+ }
33
+ if (count>=(m[i]-m[k]+1 )){
34
+ flag=true ;
35
+ }
36
+ else {
37
+ flag=false ;
38
+ break ;
39
+ }
40
+ }
41
+ }
42
+ if (flag){
43
+ cout<<" YES" <<endl;
44
+ }
45
+ else {
46
+ cout<<" NO" <<endl;
47
+ }
48
+ return 0 ;
49
+ }
50
+ int main ()
51
+ {
52
+ int testCase=1 ;
53
+ cin>>testCase;
54
+ while (testCase--){
55
+ solve ();
56
+ }
57
+ return 0 ;
58
+ }
You can’t perform that action at this time.
0 commit comments