# Codeforces Round #436 (Div. 2)

/Tag: Codeforces Round #436 (Div. 2)

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

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

#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+06:00September 26th, 2017|Categories: C/C++, Programming||

#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+06:00September 26th, 2017|Categories: Uncategorized||

#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+06:00September 26th, 2017|Categories: C/C++, Programming||

#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+06:00September 26th, 2017|Categories: C/C++, Programming||

#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+06:00September 26th, 2017|Categories: C/C++, Programming||

#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 [...]