Skip to content

Commit 7fa5f0d

Browse files
committed
codeforces 1749
1 parent 0dfdca2 commit 7fa5f0d

File tree

4 files changed

+171
-1
lines changed

4 files changed

+171
-1
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n,m;
22+
cin>>n>>m;
23+
map<int,int> row,col;
24+
for(int i=0;i<m;i++){
25+
int a,b;
26+
cin>>a>>b;
27+
row[a]++;
28+
col[b]++;
29+
}
30+
int countR=0,countC=0;
31+
for(int i=1;i<=n;i++){
32+
if(row[i]==0)
33+
countR++;
34+
if(col[i]==0)
35+
countC++;
36+
}
37+
if (countR && countC)
38+
{
39+
cout<<"YES"<<endl;
40+
}
41+
else{
42+
cout<<"NO"<<endl;
43+
}
44+
return 0;
45+
}
46+
int main()
47+
{
48+
long long testCase;
49+
cin>>testCase;
50+
while(testCase--){
51+
solve();
52+
}
53+
return 0;
54+
}
55+
/* -----------------END OF PROGRAM --------------------*/
56+
/*
57+
* stuff you should look before submission
58+
* constraint and time limit
59+
* int overflow
60+
* special test case (n=0||n=1||n=2)
61+
* don't get stuck on one approach if you get wrong answer
62+
*/
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
/* ascii value
11+
A=65,Z=90,a=97,z=122
12+
*/
13+
14+
// Techniques :
15+
// divide into cases, brute force, pattern finding
16+
// sort, greedy, binary search, two pointer
17+
// transform into graph
18+
19+
20+
int solve(){
21+
int n;
22+
cin>>n;
23+
vector<pair<ll,ll>> v(n);
24+
ll ans=0;
25+
for(int i=0;i<n;i++){
26+
cin>>v[i].second;
27+
ans+=v[i].second;
28+
}
29+
for(int i=0;i<n;i++){
30+
cin>>v[i].first;
31+
ans+=v[i].first;
32+
}
33+
sort(v.begin(),v.end());
34+
ans-=v[n-1].first;
35+
cout<<ans<<endl;
36+
return 0;
37+
}
38+
int main()
39+
{
40+
long long testCase;
41+
cin>>testCase;
42+
while(testCase--){
43+
solve();
44+
}
45+
return 0;
46+
}
47+
/* -----------------END OF PROGRAM --------------------*/
48+
/*
49+
* stuff you should look before submission
50+
* constraint and time limit
51+
* int overflow
52+
* special test case (n=0||n=1||n=2)
53+
* don't get stuck on one approach if you get wrong answer
54+
*/
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+
typedef long long ll ;
6+
7+
8+
/* ascii value
9+
A=65,Z=90,a=97,z=122
10+
*/
11+
12+
/* --------------------MAIN PROGRAM----------------------------*/
13+
// to run ctrl+b
14+
const ll INF=1e18;
15+
const ll mod1=1e9+7;
16+
const ll mod2=998244353;
17+
// Techniques :
18+
// divide into cases, brute force, pattern finding
19+
// sort, greedy, binary search, two pointer
20+
// transform into graph
21+
22+
// Experience :
23+
// Cp is nothing but only observation and mathematics.
24+
25+
26+
//Add main code here
27+
28+
class Solution
29+
{
30+
public:
31+
int tribonacci(int n)
32+
{
33+
vector<int> dp(n+1,0);
34+
dp[0]=0;
35+
if(n==0)
36+
return dp[0];
37+
dp[1]=1;
38+
if(n==1)
39+
return dp[1];
40+
dp[2]=1;
41+
for(int i=3;i<=n;i++){
42+
dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
43+
}
44+
return dp[n];
45+
}
46+
};
47+
48+
/* -----------------END OF PROGRAM --------------------*/
49+
/*
50+
* stuff you should look before submission
51+
* constraint and time limit
52+
* int overflow
53+
* special test case (n=0||n=1||n=2)
54+
* don't get stuck on one approach if you get wrong answer
55+
*/

LeetCode/70.Climbing_Stairs.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Solution {
99
else
1010
{
1111
vector<int> dp(n+1,0);
12-
dp[0]=0;
1312
dp[1]=1;
1413
dp[2]=2;
1514
for(int i=3;i<=n;i++)

0 commit comments

Comments
 (0)