Skip to content

Commit 7cdd3fa

Browse files
committed
many contest file
1 parent f9efce0 commit 7cdd3fa

16 files changed

+1829
-0
lines changed

Automated_Script_to_Create_File.sh

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ if [ "$platform_name" == "Leetcode" ]
4343
then
4444
read_file="LeetCode.cpp"
4545

46+
elif [ "$platform_name" == "AtCoder" ]
47+
then
48+
read_file="../../Atcoder.cpp"
49+
4650
else
4751
read_file="Cf.cpp"
4852
fi

Codechef/BRKNLIFE.cpp

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Codeforces{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Codeforces(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s){
76+
stringstream pk(s);
77+
ll num;
78+
pk>>num;
79+
return num;
80+
}
81+
82+
string num_to_str(ll num){
83+
return to_string(num);
84+
}
85+
// Techniques :
86+
// divide into cases, brute force, pattern finding
87+
// sort, greedy, binary search, two pointer
88+
// transform into graph
89+
90+
// Experience :
91+
// Cp is nothing but only observation and mathematics.
92+
ll solve(){
93+
string s,a;
94+
ll n,m;
95+
cin>>n>>m>>s>>a;
96+
ll pos=0;
97+
for(ll i=0;i<sz(s);i++){
98+
if(pos==sz(a)){
99+
cout<<-1<<endl;
100+
return 0;
101+
}
102+
if(s[i]==a[pos]){
103+
pos++;
104+
}
105+
else{
106+
if(s[i]=='?'){
107+
char ch=a[pos];
108+
ch++;
109+
if(ch=='f'){
110+
ch='a';
111+
}
112+
s[i]=ch;
113+
}
114+
else{
115+
continue;
116+
}
117+
}
118+
}
119+
if(pos==sz(a)){
120+
cout<<-1<<endl;
121+
return 0;
122+
}
123+
else{
124+
cout<<s<<endl;
125+
}
126+
return 0;
127+
}
128+
};
129+
130+
131+
/* --------------------MAIN PROGRAM----------------------------*/
132+
133+
int main()
134+
{
135+
speed;
136+
/* #ifndef ONLINE_JUDGE
137+
freopen("input.txt","r",stdin);
138+
freopen("output.txt","w",stdout);
139+
#endif */
140+
ll TestCase=1;
141+
cin>>TestCase;
142+
while(TestCase--){
143+
Codeforces cf;
144+
cf.solve();
145+
}
146+
}
147+
/* -----------------END OF PROGRAM --------------------*/
148+
/*
149+
* stuff you should look before submission
150+
* constraint and time limit
151+
* int overflow
152+
* special test case (n=0||n=1||n=2)
153+
* don't get stuck on one approach if you get wrong answer
154+
*/

Codechef/DISTDILEM.cpp

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
*/
5+
#include <bits/stdc++.h>
6+
#include <ext/pb_ds/assoc_container.hpp>
7+
#include <ext/pb_ds/tree_policy.hpp>
8+
using namespace std;
9+
using namespace __gnu_pbds;
10+
typedef long long ll ;
11+
typedef vector<ll> vl;
12+
typedef vector<vector<ll>> vvl;
13+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
14+
/* Abbrevations */
15+
#define ff first
16+
#define ss second
17+
#define mp make_pair
18+
#define line cout<<endl;
19+
#define pb push_back
20+
// Some print
21+
#define no cout<<"NO"<<endl;
22+
#define yes cout<<"YES"<<endl;
23+
// sort
24+
#define all(V) (V).begin(),(V).end()
25+
#define srt(V) sort(all(V))
26+
#define srtGreat(V) sort(all(V),greater<ll>())
27+
// some extra
28+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
29+
#define precision(x) cout<<fixed<<setprecision(x);
30+
#define sz(V) ll(V.size())
31+
// datatype definination
32+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
33+
34+
35+
class Codeforces{
36+
private:
37+
// read only variable
38+
const ll INF=1e18;
39+
const ll mod1=1e9+7;
40+
const ll mod2=998244353;
41+
42+
43+
public:
44+
Codeforces(){
45+
46+
}
47+
48+
ll power(ll x,ll y){
49+
ll result=1;
50+
while(y>0){
51+
if(y&1){
52+
result*=x;
53+
}
54+
y>>=1;
55+
x*=x;
56+
}
57+
return result;
58+
}
59+
60+
ll power(ll x,ll y,ll mod){
61+
ll result=1;
62+
x%=mod;
63+
while(y>0){
64+
if(y&1){
65+
result*=x;
66+
result%=mod;
67+
}
68+
y>>=1;
69+
x*=x;
70+
x%=mod;
71+
}
72+
return result;
73+
}
74+
75+
ll str_to_num(string s){
76+
stringstream pk(s);
77+
ll num;
78+
pk>>num;
79+
return num;
80+
}
81+
82+
string num_to_str(ll num){
83+
return to_string(num);
84+
}
85+
// Techniques :
86+
// divide into cases, brute force, pattern finding
87+
// sort, greedy, binary search, two pointer
88+
// transform into graph
89+
90+
// Experience :
91+
// Cp is nothing but only observation and mathematics.
92+
93+
ll solve(){
94+
ll n;
95+
cin>>n;
96+
ll sum=0;
97+
for(ll i=0;i<n;i++){
98+
ll temp;
99+
cin>>temp;
100+
sum+=temp;
101+
}
102+
103+
ll ans=0;
104+
for(ll i=1;sum>=(i*(i+1))/2;i++){
105+
ll temp2=(i*(i+1))/2;
106+
if(temp2<=sum){
107+
ans=i;
108+
}
109+
else{
110+
break;
111+
}
112+
}
113+
cout<<ans<<endl;
114+
return 0;
115+
}
116+
};
117+
118+
119+
/* --------------------MAIN PROGRAM----------------------------*/
120+
121+
int main()
122+
{
123+
speed;
124+
/* #ifndef ONLINE_JUDGE
125+
freopen("input.txt","r",stdin);
126+
freopen("output.txt","w",stdout);
127+
#endif */
128+
ll TestCase=1;
129+
cin>>TestCase;
130+
while(TestCase--){
131+
Codeforces cf;
132+
cf.solve();
133+
}
134+
}
135+
/* -----------------END OF PROGRAM --------------------*/
136+
/*
137+
* stuff you should look before submission
138+
* constraint and time limit
139+
* int overflow
140+
* special test case (n=0||n=1||n=2)
141+
* don't get stuck on one approach if you get wrong answer
142+
*/

0 commit comments

Comments
 (0)