From 44a3612677454247497cdc9e2d1256639f8be5e1 Mon Sep 17 00:00:00 2001 From: Tushar-0008 <66563056+Tushar-0008@users.noreply.github.com> Date: Wed, 30 Sep 2020 23:41:05 +0530 Subject: [PATCH] Added Solutions Solutions to some of the codeforces problems. --- Codeforces/1345B.cpp | 45 ++++ Codeforces/1346E.cpp | 27 +++ Codeforces/1372B.cpp | 29 +++ Codeforces/1380C.cpp | 33 +++ Codeforces/1399A.cpp | 26 +++ Codeforces/1418B.cpp | 37 ++++ Codeforces/1418C_DP.cpp | 19 ++ Codeforces/1419D1.cpp | 36 ++++ Codeforces/1419D2.cpp | 48 +++++ Codeforces/189A(dp).cpp | 21 ++ Codeforces/1932C(IMP).cpp | 0 Codeforces/455A(dp).cpp | 19 ++ Codeforces/489B.cpp | 30 +++ Codeforces/489C.cpp | 10 + Codeforces/492B.cpp | 22 ++ Codeforces/4C.cpp | 22 ++ Codeforces/580A.cpp | 26 +++ Codeforces/996A.cpp | 30 +++ Codeforces/DFS/520B.cpp | 35 +++ Netflix Page (unfinished)/JS/main.js | 0 Netflix Page (unfinished)/css/style.css | 274 ++++++++++++++++++++++++ Netflix Page (unfinished)/index.html | 193 +++++++++++++++++ 22 files changed, 982 insertions(+) create mode 100644 Codeforces/1345B.cpp create mode 100644 Codeforces/1346E.cpp create mode 100644 Codeforces/1372B.cpp create mode 100644 Codeforces/1380C.cpp create mode 100644 Codeforces/1399A.cpp create mode 100644 Codeforces/1418B.cpp create mode 100644 Codeforces/1418C_DP.cpp create mode 100644 Codeforces/1419D1.cpp create mode 100644 Codeforces/1419D2.cpp create mode 100644 Codeforces/189A(dp).cpp create mode 100644 Codeforces/1932C(IMP).cpp create mode 100644 Codeforces/455A(dp).cpp create mode 100644 Codeforces/489B.cpp create mode 100644 Codeforces/489C.cpp create mode 100644 Codeforces/492B.cpp create mode 100644 Codeforces/4C.cpp create mode 100644 Codeforces/580A.cpp create mode 100644 Codeforces/996A.cpp create mode 100644 Codeforces/DFS/520B.cpp create mode 100644 Netflix Page (unfinished)/JS/main.js create mode 100644 Netflix Page (unfinished)/css/style.css create mode 100644 Netflix Page (unfinished)/index.html diff --git a/Codeforces/1345B.cpp b/Codeforces/1345B.cpp new file mode 100644 index 0000000..79dded6 --- /dev/null +++ b/Codeforces/1345B.cpp @@ -0,0 +1,45 @@ +#include +#include +using namespace std; +const long long MAX = 1e9; +vector pyr; //cards in pyramid + +int binarySearch(int n) +{ + int l = 0,r = pyr.size() - 1; + int ind = 0; + while(l <= r){ + int mid = l + (r - l)/2; + if(pyr[mid] == n) return mid; + if(pyr[mid] < n){ + l = mid + 1; + ind = mid; + } + else{ + r = mid - 1; + } + } + return ind; +} + +int main(){ + long long sum =0; + for(int i =1;sum<=MAX;i++){ + pyr.push_back(sum); + sum += 3*i-1; + } + int t; + cin>>t; + while(t--){ + int n; + cin>>n; + int ans =0; + int i = binarySearch(n); + while(i>0&&n>0){ + n -= pyr[i]; + ans ++; + i = binarySearch(n); + } + cout< +#include +using namespace std; + +int main(){ + int n,m,k; + cin>>n>>m>>k; + int ans[n]; + for (int i = 0; i < n; ++i) + { + ans[i] = 2*10e6; + } + ans[k-1]=0; + while(m--){ + int x; + int y; + cin>>x>>y; + int ix = ans[x]; + int iy = ans[y]; + ans[x] = min(ix+1, iy); + ans[y] = min(iy+1, ix); + } + for(auto x:ans){ + cout<<((x==2*10e6)?-1:x)<<" "; + } + cout< +using namespace std; + +int main(){ + int t; + cin>>t; + while(t--){ + int n; + cin>>n; + if(n%2==0){ + cout< +#include +using namespace std; + +int main(){ + int t; + cin>>t; + while(t--){ + int n,x; + cin>>n>>x; + std::vector a(n); + for (int i = 0; i < n; ++i) + { + cin>>a[i]; + } + sort(a.begin(),a.end(),greater()); + int c =1; + int ans =0; + for (int i = 0; i < n; ++i) + { + if(a[i]*c>=x){ + ans += 1; + c =0; + } + c++; + + } + cout< +using namespace std; + +int main(){ + int t; + cin>>t; + while(t--){ + int n; + cin>>n; + int a[n]; + for(int i =0;i>a[i]; + } + sort(a,a+n); + bool ans = true; + for(int i=1;i1){ + ans = false; + break; + } + } + if(ans) cout<<"YES"< +using namespace std; + +int main(){ + int t; + cin>>t; + while(t--){ + int n; + cin>>n; + int a[n], l[n]; + vector d; + for(auto &x:a){ + cin>>x; + } + for(int i=0;i>l[i]; + if(l[i]==0){ + d.push_back(a[i]); + } + } + vector::iterator j; + sort(d.begin(),d.end()); + reverse(d.begin(), d.end()); + j = d.begin(); + for(int i =0;i +using namespace std; + +int solve(int n, int a[]) + +int main(){ + int t; + cin>>t; + while(t--){ + int n; + cin<>x; + } + c = solve(n,a); + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + int a[n]; + for(auto &x:a){ + cin>>x; + } + sort(a, a+n); + int ans =0; + if(n>2){ + if(n%2==0){ + for(int i =0;i+2 +using namespace std; + +int main(){ + int n; + cin>>n; + int a[n]; + for(auto &x:a){ + cin>>x; + } + sort(a, a+n); + int ans =0; + if(n>2){ + if(n%2==0){ + for(int i =0;i+2 +using namespace std; + int dp[4001] ={INT_MIN}; + int a,b,c; + + int main(){ + int n, a[3]; + cin>>n>>a[0]>>a[1]>>a[2]; + sort(a,a+3); + dp[0] =0; + for(int i=0;i=0){ + dp[i] = max(dp[i],dp[i-a[j]]); + } + } + dp[i] += 1; + } + cout< +using namespace std; +#define MAXN 100005 +long long occurance[MAXN] ={0}; +long long ans[MAXN] ={0}; +int main(){ + int n,x; + cin>>n; + while(n--){ + cin>>x; + occurance[x]++; + } + ans[1]=occurance[1]; + for(int i=2;i +using namespace std; +int main(){ + int n,m; + cin>>n; + int b[n]; + for(auto &x : b){ + cin>>x; + } + cin>>m; + int g[m]; + for(auto &x : g){ + cin>>x; + } + int i=0,j=0,p=0; + sort(b, b+n); + sort(g,g+m); + while(j +using namespace std; + +int main(){ + int m,s; + cin>>m>>s; + + + return 0; +} diff --git a/Codeforces/492B.cpp b/Codeforces/492B.cpp new file mode 100644 index 0000000..61498b9 --- /dev/null +++ b/Codeforces/492B.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int main(){ + int n,l; + cin>>n>>l; + int a[n]; + for(int i=0;i>a[i]; + } + sort(a,a+n); + int d = max(a[0]-0, l-a[n-1])*2; + for(int i=0;i=d){ + d = temp; + } + } + cout.precision(10); + cout< +#include +#include +using namespace std; + +int main(){ + map a; + int n; + cin>>n; + while(n--){ + string temp; + cin>>temp; + if(a.count(temp)){ + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + int a[n]; + for(int i=0;i>a[i]; + } + int dp[n]; + dp[0] =1; + int m =1; + for(int i=1;i= a[i-1]){ + dp[i] = 1+ dp[i-1]; + m = max(dp[i],m); + } + else{ + dp[i] = 1; + } + } + cout< +using namespace std; + +int main(){ + int n; + cin>>n; + int ans =0; + if(n/100){ + ans += n/100; + n -= (n/100)*100; + } + if(n/20){ + ans += n/20; + n -= (n/20)*20; + } + if(n/10){ + ans += n/10; + n -= (n/10)*10; + } + if(n/5){ + ans += n/5; + n -= (n/5)*5; + } + if(n>0){ + ans += n; + } + cout< +using namespace std; + +int bfs(int x, int y){ + std::vector v(10002,false); + v[x] = true; + std::queue> q; //value,distance + q.push(x,0); + while(!q){ + pair p = q.front(); + q.pop(); + v[p.first] = true; + if(p.first==y){ + return(p.second); + } + else{ + if(p.first*2==y){ + return(p.second +1); + } + else if(p.first*20&&v[p.first-1]==false) q.push(p.first-1,p.second+1); + } + } + return 0; +} + +int main(){ + int n,m; + cin>>n>>m; + int c = bfs(n,m); + cout< div { + padding : 1.5 0; +} +.tabs .container > div:hover { + color: white; + cursor: pointer; +} +.tab-border { + border-bottom: var(--primary-color) 4px solid; +} +/* tab content */ +.tab-content { + padding 3rem 0; + color: #fff; +} +#tab-1-content .tab-1-content-inner { + display: grid; + grid-template-columns: repeat(2,1fr); + grid-gap: 2rem; + justify-content: center; + align-items: center; +} + +#tab-2-content .tab-2-content-top { + margin-top: 2rem; + display: grid; + grid-template-columns: 2fr 1fr; + grid-gap: 1rem; + justify-content: center; + align-items: center; + +} +#tab-2-content .tab-2-content-bottom { + margin-top: 2rem; + display: grid; + grid-template-columns: 1fr 1fr 1fr; + grid-gap: 2rem; + justify-content: center; + align-items: center; + text-align: center; + +} +.table { + width: 100%; + margin-top: 2rem; + border-collapse: collapse; + border-spacing: 0; +} +.table thead th { + text-transform: uppercase; + padding : 0.8rem; +} +.table tbody tr td { + color : #999; + text-align: center; + padding: 0.8rem 1.2rem; +} +.table tbody tr td:first-child { + text-align: left; +} +.table tbody tr:nth-child(odd){ + background:#222; +} + +/* footer */ + +.footer { + max-width: 70%; + margin: 1rem auto; +} + +.footer a { + color: #999; +} + +.footer .footer-cols{ + display: grid; + grid-template-columns: repeat(4,1fr); + grid-gap: 2rem; + +} +.footer li { + line-height: 1.9; +} +/* COntainer */ +.container { + max-width: 70%; + margin: auto; + padding : 0 2rem; +} + +/* text */ + +.text-lg { + font-size: 1.8rem; + margin-bottom: 1rem; +} +.text-md { + font-size: 1.5rem; + margin-bottom: 1rem; +} +.text-center { + text-align: center; +} + +.text-dark { + color: #999; +} + + +/* Buttons */ + +.btn { + display: inline-block; + background: var(--primary-color); + color: #fff; + padding: 0.4rem, 1.3rem; + text-align: center; + cursor: pointer; + border: none; + font-size: 1rem; + margin-right: 0.5rem; + outline: none; + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45); + border-radius: 2px; +} + +.btn:hover { + opacity: 0.9; +} + +.btn-rounded { + border-radius: 5px; +} + +.btn-xl { + font-size: 2rem; + padding: 1.5rem 2.1rem; + text-transform: uppercase; +} + +.btn-lg { + font-size: 1rem; + padding: 0.8rem 1.3rem; + text-transform: uppercase; +} diff --git a/Netflix Page (unfinished)/index.html b/Netflix Page (unfinished)/index.html new file mode 100644 index 0000000..ea5b8bb --- /dev/null +++ b/Netflix Page (unfinished)/index.html @@ -0,0 +1,193 @@ + + + + + + Netflix Watch tv shows online + + + + +
+
+ netflix + Sign In +
+
+

See what's next.

+

Watch anywhere. Cancel anytime.

+ + Watch Free For 30 Days + +
+
+
+
+
+ +

Cancel at any time

+
+
+ +

Watch anywhere

+
+
+ +

Pick your price

+
+
+
+
+
+ + + + + + +
+
+

+ Choose one plan and watch everything on Netflix. +

+ Watch Free For 30 Days +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BasicStandardPremium
Monthly price after free month ends on 6/19/19$8.99$12.99$15.99
HD Available
Ultra HD Available
Screens you can watch on at the same time124
Watch on your laptop, TV, phone and tablet
Unlimited movies and TV shows
Cancel anytime
First month free
+
+
+
+ + +