About Admin

This author has not yet filled in any details.
So far Admin has created 596 blog entries.

Codeforces Round #387 (Div. 2), problem: (E) Comments Solution in C/C++

By |2017-04-07T22:11:45+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #387 (Div. 2), problem: (E) Comments Solution in C/C++   #include <stdio.h> #include <string.h> #include <stdlib.h> #define N 1000000 int ccnt; struct comment { char *s; int d, i; } cc[N]; char *ss[N]; int parse(int d, int i) { int k = [...]

Codeforces Round #387 (Div. 2), problem: (D) Winter Is Coming Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #387 (Div. 2), problem: (D) Winter Is Coming Solution in C/C++     #include <limits.h> #include <stdio.h> #include <stdlib.h> int compare(const void *a, const void *b) { int *pa = (int *) a; int *pb = (int *) b; return *pb - [...]

Codeforces Round #387 (Div. 2), problem: (C) Servers Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #387 (Div. 2), problem: (C) Servers Solution in C/C++   #include<stdio.h> int main(){ int n,q,a[100]={0},t,k,d,i,j,s,f; scanf("%d%d",&n,&q); while(q>0) { scanf("%d%d%d",&t,&k,&d); s=0; for(i=0;i<n;i++) { if(a[i]<t) a[i]=0; } j=0; for(i=0;i<n;i++) { if(a[i]==0) j++; } if(j<k) printf("-1\n"); else {for(i=0,j=0;i<n&&j<k;i++) { if(a[i]==0) { s+=i+1; a[i]=t+d-1;j++;} } printf("%d\n",s);} [...]

Codeforces Round #387 (Div. 2), problem: (B) Mammoth’s Genome Decoding Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #387 (Div. 2), problem: (B) Mammoth's Genome Decoding Solution in C/C++   #include <stdio.h> char cc[] = { 'A', 'C', 'G', 'T' }; int cnt[4]; void incr(char c) { int i; for (i = 0; i < 4; i++) if (cc[i] == [...]

Codeforces Round #387 (Div. 2), problem: (A) Display Size Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #387 (Div. 2), problem: (A) Display Size Solution in C/C++   int main(){ long long int x,i; scanf("%I64d",&x); i=sqrt(x); while(x%i){ i--; } printf("%I64d %I64d",i,x/i); }

Codeforces Round #386 (Div. 2), problem: (G) New Roads Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #386 (Div. 2), problem: (G) New Roads Solution in C/C++ #include<stdio.h> #include<stdlib.h> typedef unsigned u; u D[222222],H[222222],P[222222],A[222222]; int main() { u n,d,x,i=-1,j,k,mi=0,ma=1; for(scanf("%u%u%u",&n,&d,&x);++i<d;)scanf("%u",D+i); for(i=d;i--;ma+=D[i]-1)if(D[i]>D[i+1])mi+=D[i]-D[i+1]; if(x<mi||x>ma){printf("-1\n");return 0;} for(A[i=0]=2;i++<d;)A[i]=A[i-1]+D[i-1]; for(i=1;++i<A[1];)P[i]=1; for(i=0;++i<d;) { k=D[i-1]-1; if(k>D[i]-1)k=D[i]-1; j=ma-x; if(j>k)j=k; ma-=j; j=A[i]-1-j; for(k=A[i]-1;++k<A[i+1];) { P[k]=j; if(j+1<A[i])++j; } } [...]

Codeforces Round #386 (Div. 2), problem: (F) Music in Car Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #386 (Div. 2), problem: (F) Music in Car Solution in C/C++   #include <stdio.h> #include <string.h> #define MAX(X,Y) ((X)>(Y) ? (X) : (Y)) int n,w,k,a[200010],t[200010],sz[2],heap[2][200010],ind[200010],pos[200010]; void push(int k,int opt); int pop(int opt); void del(int u,int opt); void up(int u,int opt); void down(int [...]

Codeforces Round #386 (Div. 2), problem: (E) Numbers Exchange Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #386 (Div. 2), problem: (E) Numbers Exchange Solution in C/C++     #include<stdio.h> #include<stdlib.h> typedef unsigned u; u N[222222],X[222222],C[222222],H[222222]; int F(const void*x,const void*y) { if(N[*(u*)x]>N[*(u*)y])return 1; if(N[*(u*)x]<N[*(u*)y])return-1; return 0; } int main() { u n,m,i,o,e,h,os=1,es=2,g=0; scanf("%u%u",&n,&m);h=n>>1; if(n&1){printf("-1\n");return 0;} for(i=-1;++i<n;X[i]=i)scanf("%u",N+i); qsort(X,n,sizeof(u),F); for(i=o=e=0;++i<n;)if(N[X[i]]==N[X[i-1]])C[X[i]]=1; for(i=n;i--;)if(!C[X[i]]) [...]

Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , |

Codeforces Round #386 (Div. 2), problem: (D) Green and Black Tea Solution in C/C++     #include<stdio.h> int main() { long long n,k,a,b,i; char x='G',y='B'; int num=0; scanf("%I64d%I64d%I64d%I64d",&n,&k,&a,&b); if(a>b) { int t=a;a=b;b=t; char z=x;x=y;y=z; } if(b>(a+1)*(k)) { printf("NO\n"); return 0; } for(i=0;i<n;i++){ if(b>a&&num<k){printf("%c",y);b--;num++;} else [...]

Codeforces Round #386 (Div. 2), problem: (C) Tram Solution in C/C++

By |2017-04-07T22:11:46+00:00January 6th, 2017|Categories: C/C++, Programming|Tags: , , , , , , , |

Codeforces Round #386 (Div. 2), problem: (C) Tram Solution in C/C++ #include<stdio.h> typedef unsigned u; u x1,x2,s; u F(u p,u d,u k) { if(k==2)return-1; if(!p&&d==-1u)return F(p,-d,k); if(p==s&&d==1)return F(p,-d,k); if(k==1&&p==x2)++k; if(k==0&&p==x1)++k; return 1+F(p+d,d,k); } int main() { u t1,t2,p,d,a,b; scanf("%u%u%u%u%u%u%u",&s,&x1,&x2,&t1,&t2,&p,&d); a=F(p,d,0)*t1; b=(x1>x2?x1-x2:x2-x1)*t2; printf("%u\n",a>b?b:a); return 0; [...]