Skip to content

Commit 37f8a74

Browse files
committed
cf global round 14
1 parent f60d368 commit 37f8a74

10 files changed

+915
-0
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
written by Pankaj Kumar.
3+
country:-INDIA
4+
Institute: National Institute of Technology, Uttarakhand
5+
*/
6+
#include <bits/stdc++.h>
7+
#include <ext/pb_ds/assoc_container.hpp>
8+
#include <ext/pb_ds/tree_policy.hpp>
9+
using namespace std;
10+
using namespace __gnu_pbds;
11+
typedef long long ll ;
12+
typedef unsigned long long ull;
13+
typedef vector<ll> vl;
14+
#define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
15+
/* Abbrevations */
16+
#define ff first
17+
#define ss second
18+
#define mp make_pair
19+
#define line cout<<endl;
20+
#define pb push_back
21+
#define Endl "\n"
22+
// loops
23+
#define forin(arr,n) for(ll i=0;i<n;i++) cin>>arr[i];
24+
// Some print
25+
#define no cout<<"No"<<endl;
26+
#define yes cout<<"Yes"<<endl;
27+
// sort
28+
#define all(V) (V).begin(),(V).end()
29+
#define srt(V) sort(all(V))
30+
#define srtGreat(V) sort(all(V),greater<ll>())
31+
// some extra
32+
#define printv(v) for(ll i=0;i<ll(v.size());i++){cout<<v[i]<<" ";} line;
33+
#define precision(x) cout<<fixed<<setprecision(x);
34+
#define sz(V) ll(V.size())
35+
// template
36+
template <typename T>
37+
T mymax(T x,T y)
38+
{
39+
return (x>y)?x:y;
40+
}
41+
// function
42+
ll power(ll x,ll y,ll mod)
43+
{
44+
ll res=1;
45+
// x=x%mod;
46+
while(y>0)
47+
{
48+
if(y%2==1)
49+
{
50+
res*=x;
51+
// res=res%mod;
52+
}
53+
y/=2; x*=x; // x=x%mod;
54+
}
55+
return res;
56+
}
57+
ll str_to_num(string s)
58+
{
59+
return stoi(s);
60+
}
61+
62+
string num_to_str(ll num)
63+
{
64+
return to_string(num);
65+
}
66+
// datatype definination
67+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
68+
class Point
69+
{
70+
public:
71+
ll x;
72+
ll y;
73+
ll z;
74+
ll getsum()
75+
{
76+
return x+y+z;
77+
}
78+
};
79+
/* ascii value
80+
A=65,Z=90,a=97,z=122
81+
*/
82+
/* --------------------MAIN PROGRAM----------------------------*/
83+
// to run ctrl+b
84+
const ll INF=LONG_MAX;
85+
const ll mod1=1e9+7;
86+
const ll mod2=998244353;
87+
88+
89+
// Techniques
90+
// divide into cases, brute force, pattern finding
91+
// sort, greedy, binary search, two pointer
92+
// transform into graph
93+
94+
ll solve()
95+
{
96+
string s;
97+
cin>>s;
98+
ll ans=0;
99+
for(ll i=0;i<sz(s);i++){
100+
if(s.substr(i,4)=="ZONe")
101+
ans++;
102+
}
103+
cout<<ans<<endl;
104+
return 0;
105+
}
106+
107+
int main()
108+
{
109+
speed;
110+
/* #ifndef ONLINE_JUDGE
111+
freopen("input.txt","r",stdin);
112+
freopen("output.txt","w",stdout);
113+
#endif */
114+
ll TestCase=1;
115+
// cin>>TestCase;
116+
while(TestCase--)
117+
{
118+
solve();
119+
}
120+
}
121+
/* -----------------END OF PROGRAM --------------------*/
122+
/*
123+
* stuff you should look before submission
124+
* constraint and time limit
125+
* int overflow
126+
* special test case (n=0||n=1||n=2)
127+
* don't get stuck on one approach if you get wrong answer
128+
*/

Codeforces/1515A-Phoenix_and_Gold.cpp

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

0 commit comments

Comments
 (0)