# Programming Archive

## Codeforces Round #443 (Div. 2), problem: (A) Borya’s Diagnosis Solution In C/C++

#include<bits/stdc++.h> using namespace std; int main() { int n,i,s,d,t=0; cin>>n; for(i=0;i<n;i++) { cin>>s>>d; while(s<=t) { s=s+d; } t=s; } cout<<s<<endl; }

## Codeforces Round #444 (Div. 2), problem: (F) Row of Models Solution In C/C++

#include<bits/stdc++.h> #define maxn 1000050 using namespace std; int a,b,c,n,k,m,t; int main() { scanf("%d%d",&n,&k); for (int i=0;i<n;i++) scanf("%d",&a); a=0; memset(c,-1,sizeof(c)); m=0;b=0;c=0;t=0; for (int i=1;i<=n;i++) if (a<a]) b=i,c=m; for (int i=1;i<=m;i++) if (b-b>2*k) {puts("NO");return 0;} else if …

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

#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algorithm> #include<cstdlib> #define eps 1e-7 using namespace std; double x,y,r,L; struct node{double l,r;}a; struct P{double x,y;}A,B,M,s,O,p; 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};} …

## Codeforces Round #444 (Div. 2), problem: (D) Ratings and Reality Shows Solution In C/C++

#include <cstdio> #include <algorithm> using namespace std; long long n,a,b,c,d,st,len,t; int q; int main() { scanf(“%lld%lld%lld%lld%lld%lld%lld”,&n,&a,&b,&c,&d,&st,&len); for (int i=1;i<=n;i++) scanf(“%lld%d”,&t,&q); t=-1; int now=1; long long change_rating=0,Min=0,rating=st; for (int i=1;i<=n;i++) { while (now<=n&&t-t<len) { change_rating+=(q?c:-d); Min=min(Min,change_rating); …

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

#include <bits/stdc++.h> using namespace std; const int R = { {12, 13, 4, 5, 16, 17, 20, 21}, {14, 15, 6, 7, 18, 19, 22, 23}, { 0, 2, 4, 6, 8, 10, 23, 21}, …

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

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

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

#include<stdio.h> char s; int main() { scanf(” %s”,s); int x=0,y=0,z=0; while(s==’0′) x++; while(s!=0) z++; for(int i=x+1;i<z;i++) if(s==’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++

#include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int N = 3005, INF = 0x3f3f3f3f; int n, m, q, f; bool vis; struct Edge { int to; Edge *next; Edge () {} Edge (int to, Edge …

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

#include<iostream> #include<cstdio> #include<algorithm> #include<bitset> using namespace std; struct node{ int t,d,p,tot; }a; int f; bool cmp(node x,node y){ return x.d<y.d; } bitset<150> ans; int cc; int main(){ int n; scanf(“%d”,&n); for (int i=1;i<=n;++i){ scanf(“%d%d%d”,&a.t,&a.d,&a.p); a.tot=i; …

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

#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; }