Skip to content

Commit 2b38397

Browse files
committed
div 3 cf contest
1 parent d42c5e8 commit 2b38397

20 files changed

+2517
-22
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
// 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]<<" ";} cout<<endl;
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+
stringstream pk(s);
60+
ll num;
61+
pk>>num;
62+
return num;
63+
}
64+
string num_to_str(ll num)
65+
{
66+
return to_string(num);
67+
}
68+
// datatype definination
69+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
70+
/* ascii value
71+
A=65,Z=90,a=97,z=122
72+
*/
73+
74+
/* Some syntax
75+
//Syntax to create a min heap for priority queue
76+
//priority_queue <int, vector<int>, greater<int>>pq;
77+
*/
78+
79+
80+
/* --------------------MAIN PROGRAM----------------------------*/
81+
// to run ctrl+b
82+
const ll INF=1e18;
83+
const ll mod1=1e9+7;
84+
const ll mod2=998244353;
85+
86+
87+
// Techniques :
88+
// divide into cases, brute force, pattern finding
89+
// sort, greedy, binary search, two pointer
90+
// transform into graph
91+
// Experience :
92+
// Cp is nothing but only observation and mathematics.
93+
94+
95+
ll solve()
96+
{
97+
ll n,total;
98+
cin>>n>>total;
99+
ll temp=total/n;
100+
ll remain=total%n;
101+
vl ans(n,temp);
102+
vector<pair<ll,ll>> v(n);
103+
for(ll i=0;i<n;i++){
104+
ll temp1;
105+
cin>>temp1;
106+
v[i]={temp1,i};
107+
}
108+
srt(v);
109+
for(ll i=0;i<remain;i++){
110+
ans[v[i].ss]++;
111+
}
112+
for(auto x:ans){
113+
cout<<x<<endl;
114+
}
115+
return 0;
116+
}
117+
int main()
118+
{
119+
speed;
120+
/* #ifndef ONLINE_JUDGE
121+
freopen("input.txt","r",stdin);
122+
freopen("output.txt","w",stdout);
123+
#endif */
124+
ll TestCase=1;
125+
//cin>>TestCase;
126+
while(TestCase--)
127+
{
128+
solve();
129+
}
130+
}
131+
/* -----------------END OF PROGRAM --------------------*/
132+
/*
133+
* stuff you should look before submission
134+
* constraint and time limit
135+
* int overflow
136+
* special test case (n=0||n=1||n=2)
137+
* don't get stuck on one approach if you get wrong answer
138+
*/

Codechef/Practice/XXOORR.cpp

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
// 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+
stringstream pk(s);
60+
ll num;
61+
pk>>num;
62+
return num;
63+
}
64+
string num_to_str(ll num)
65+
{
66+
return to_string(num);
67+
}
68+
// datatype definination
69+
#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
70+
/* ascii value
71+
A=65,Z=90,a=97,z=122
72+
*/
73+
74+
/* Some syntax
75+
//Syntax to create a min heap for priority queue
76+
//priority_queue <int, vector<int>, greater<int>>pq;
77+
*/
78+
79+
80+
/* --------------------MAIN PROGRAM----------------------------*/
81+
// to run ctrl+b
82+
const ll INF=1e18;
83+
const ll mod1=1e9+7;
84+
const ll mod2=998244353;
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+
{
94+
ll n,k;
95+
cin>>n>>k;
96+
vl bits_count(32,0);
97+
for(ll i=0;i<n;i++){
98+
ll temp;
99+
cin>>temp;
100+
ll pos=0;
101+
while(temp){
102+
if(temp&1){
103+
bits_count[pos]++;
104+
}
105+
pos++;
106+
temp>>=1;
107+
}
108+
}
109+
ll ans=0;
110+
for(auto x:bits_count){
111+
ans+=(x+k-1)/k;
112+
}
113+
cout<<ans<<endl;
114+
return 0;
115+
}
116+
int main()
117+
{
118+
speed;
119+
/* #ifndef ONLINE_JUDGE
120+
freopen("input.txt","r",stdin);
121+
freopen("output.txt","w",stdout);
122+
#endif */
123+
ll TestCase=1;
124+
cin>>TestCase;
125+
while(TestCase--)
126+
{
127+
solve();
128+
}
129+
}
130+
/* -----------------END OF PROGRAM --------------------*/
131+
/*
132+
* stuff you should look before submission
133+
* constraint and time limit
134+
* int overflow
135+
* special test case (n=0||n=1||n=2)
136+
* don't get stuck on one approach if you get wrong answer
137+
*/

0 commit comments

Comments
 (0)