Codeforces Solution, Codeforces.com solution,codeforces div 1 solution, codeforces division 1 solution,codeforces div 2 solution, codeforces division 2 solution,Codeforces problem,codeforcesproblem solution,codeforces regular problem solution,codeforces regular,c programming sample programms, c programming examples,c++ regular programms, c++ programming examples,programmng language , basic programming,easy programming example,easy programming solutions,C language, c language solutions, c language examples,Codeforces solve, Codeforces.com solve,codeforces div 1 solve, codeforces division 1 solve,codeforces div 2 solve, codeforces division 2 solve,Codeforces problem,codeforcesproblem solve,codeforces regular problem solve,codeforces regular,c programming sample programms, c programming examples,c++ regular programms, c++ programming examples,programmng language , basic programming,easy programming example,easy programming solves,C language, c language solves, c language examples,

Codeforces Round #444 (Div. 2), problem: (E) Little Brother Solution In C/C++

By |2017-11-07T20:08:13+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<cstdlib> #define eps 1e-7 using namespace std; double x[100010],y[100010],r[100010],L; struct node{double l,r;}a[100010]; struct P{double x,y;}A,B,M,s,O,p[100010]; int n; inline double dis(P a,P b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));} inline P operator-(P a,P b){return (P){a.x-b.x,a.y-b.y};} inline double operator*(P a,P b){return a.x*b.y-a.y*b.x;} inline bool cmp(node [...]

Codeforces Round #444 (Div. 2), problem: (B) Cubes for Masha Solution In C/C++

By |2017-11-07T20:00:13+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<stdio.h> int main() { int n,i,j,k,m,A[10][10],B[1000]; scanf("%d",&n); for(i=1;i<=n;i++){ for(j=1;j<=6;j++){ scanf("%d",&A[i][j]);} } for(i=1;i<=100;i++){ B[i]=0;} for(i=1;i<=n;i++){ for(j=1;j<=6;j++){ B[A[i][j]]=1; for(k=1;k<=n;k++){ for(m=1;m<=6;m++){ if (k!=i){ B[A[i][j]*10+A[k][m]]=1; } } } } } i=1; while(B[i]){ i++;} printf("%d",i-1); return 0; }

Codeforces Round #444 (Div. 2), problem: (A) Div. 64 Solution In C/C++

By |2017-11-07T19:58:04+00:00November 7th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<stdio.h> char s[107]; int main() { scanf(" %s",s); int x=0,y=0,z=0; while(s[x]=='0') x++; while(s[z]!=0) z++; for(int i=x+1;i<z;i++) if(s[i]=='0') y++; if(y>=6) printf("yes"); else printf("no"); return 0; }

Codeforces Round #436 (Div. 2), problem: (F) Cities Excursions Solution In C/C++

By |2017-09-26T16:42:50+00:00September 26th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

#include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int N = 3005, INF = 0x3f3f3f3f; int n, m, q, f[N][12]; bool vis[N]; struct Edge { int to; Edge *next; Edge () {} Edge (int to, Edge *next) : to(to), next(next) {} }*head[N], pool[N << 1], [...]

Codeforces Round #436 (Div. 2), problem: (E) Fire Solution In C/C++

By |2017-09-26T16:40:39+00:00September 26th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<iostream> #include<cstdio> #include<algorithm> #include<bitset> using namespace std; struct node{ int t,d,p,tot; }a[200]; int f[3000]; bool cmp(node x,node y){ return x.d<y.d; } bitset<150> ans[2050]; int cc[2050]; int main(){ int n; scanf("%d",&n); for (int i=1;i<=n;++i){ scanf("%d%d%d",&a[i].t,&a[i].d,&a[i].p); a[i].tot=i; } sort(a+1,a+n+1,cmp); for (int i=1;i<=n;++i) for (int j=a[i].d-1;j>=a[i].t;--j) if [...]

Codeforces Round #436 (Div. 2), problem: (D) Make a Permutation! Solution In C/C++

By |2017-09-26T16:38:06+00:00September 26th, 2017|Categories: Uncategorized|Tags: , , , , , , , |

#include<stdio.h> int a[200005], b[200005], sum[200005], flag[200005]; int main(void) { int n, i, p, k; scanf("%d", &n); for(i=1;i<=n;i++) { scanf("%d", &a[i]); sum[a[i]]++; } k = 0; for(i=1;i<=n;i++) { if(sum[i]==0) b[++k] = i; } printf("%d\n", k); p = 1; for(i=1;i<=n;i++) { if(sum[a[i]]==1) continue; if(b[p]<a[i] || flag[a[i]]==1) [...]

Codeforces Round #436 (Div. 2), problem: (C) Bus Solution In C/C++

By |2017-09-26T16:36:31+00:00September 26th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <bits/stdc++.h> using namespace std; int main(){ int k,sum=0,end,cap,f,tank; for(cin>>end>>cap>>f>>k,tank=cap;k--;f=end-f) if(tank<f||cap<end-f) return cout<<-1,0; else if(tank>=end+(k?end-f:0)) tank-=end; else ++sum,tank=cap-(end-f); cout<<sum; }

Codeforces Round #436 (Div. 2), problem: (B) Polycarp and Letters Solution In C/C++

By |2017-09-26T16:19:34+00:00September 26th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <stdio.h> int c[26]; void reset(){ for(int i=0;i<26;i++){ c[i]=0; } } int main(){ int n,i,cur=0,max=0; scanf("%d",&n); char a[n+1]; scanf("%s",a); reset(); for(i=0;i<n;i++){ if(a[i]>='A' && a[i]<='Z'){ cur=0; reset(); } else if(c[a[i]-'a']==0){ c[a[i]-'a']++; cur++; } if(cur>max){ max=cur; } } printf("%d\n",max); return 0; }

Codeforces Round #436 (Div. 2), problem: (A) Fair Game Solution In C/C++

By |2017-09-26T16:17:26+00:00September 26th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include<cstdio> #include<iostream> using namespace std; int n,cnt,ans,A,B; int buck[500]; int main(){ scanf("%d",&n); for(int i = 1;i <= n;i++){ cin >> cnt; if(!buck[cnt]){ ans++; if(A) B = cnt; else A = cnt; } buck[cnt]++; } if(ans == 2 && buck[A] == buck[B]) printf("YES\n%d %d",A,B); else [...]

Codeforces Round #429 (Div. 1), problem: (D) Destiny Solution In C/C++

By |2017-08-21T13:20:34+00:00August 21st, 2017|Categories: C/C++, Programming|Tags: , , , , , , , , |

#include <bits/stdc++.h> using namespace std; const int maxN = 3e5+10, base = 1e9+7; int N, Q, ans, valmid, A[maxN]; bool cmp(int x) { return x <= valmid; } struct wavelet_tree { int low, high; wavelet_tree *L, *R; vector <int> tmp; wavelet_tree(int *u, int *v, [...]