Monthly Archives: July, 2017

Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals), problem: (D) Singer House Solution In C/C++

#include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #define LL long long using namespace std; const LL Maxn = 410; const LL Mod =...

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (F) Bamboo Partition Solution In C/C++

#include<cstdio> #include<algorithm> using namespace std; int n,a; long long k,ans=0; int main(){ scanf(“%d%lld”,&n,&k); for (int i=1; i<=n; i++) scanf(“%d”,&a); for (long long l=1,r; l<=1LL<<62;...

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (E) Cards Sorting Solution in C/C++

#include <bits/stdc++.h> using namespace std; set<int> s; int main() { int n,i,x; cin>>n; int m=0; for(i=0;i<n;i++) { cin>>x; s.insert(i); m=max(m,x); } i=0; long long int c=0,val=1,ans=0; while(i<=m) { if(s.size()==0) i++; else { set<int>::iterator itr=s.lower_bound(c); if(itr!=s.end()) { c=*itr; ans+=val; s.erase(itr); } else { c=0; val++; } } } cout<<ans<<endl; return 0; } 📦 Looking for Codeforces Round...

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (D) Office Keys Solution In C/C++

#include<bits/stdc++.h> using namespace std; const int maxn=2e3+5; int main(){ int n,k,p,a,b; int res=INT_MAX,i,j; cin>>n>>k>>p; for(i=0;i<n;i++) scanf(“%d”,a+i); for(i=0;i<k;i++) scanf(“%d”,b+i); sort(a,a+n); sort(b,b+k); for(i=0;i<=k-n;i++){ int t=0; for(j=0;j<n;j++) t=max(t,abs(a-b)+abs(p-b)); res=min(t,res); } cout<<res; return 0; } 📦 Looking for Codeforces Round...

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (C) Jury Marks Solution In C/C++

#include<bits/stdc++.h> using namespace std; int main(){ int n,k; cin>>k>>n; int t; int arr; set<int>c; for(int i=0;i<k;i++){ cin>>t; arr= arr+t; } for(int i=0;i<n;i++){ cin>>t; set<int>mmp; for(int j=0;j<k;j++){ int x = t-arr; if(!i||(c.find(x) != c.end())){ mmp.insert(x); } } c =mmp; } cout<<c.size(); return...

Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (B) Keyboard Layouts Solution In C/C++

#include <bits/stdc++.h> using namespace std; string s1, s2, t; int main() { cin >> s1 >> s2 >> t; for(char c :...

Codeforces Round #416 (Div. 2), problem: (E) Vladik and Entertaining Flags Solution In C/C++

#include<set> #include<map> #include<cmath> #include<queue> #include<cctype> #include<vector> #include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define Rep(i,x,y) for(int i=x;i<y;++i) #define For(i,x,y) for(int i=x;i<=y;++i) #define...

Codeforces Round #416 (Div. 2), problem: (D) Vladik and Favorite Game Solution In C/C++

#include <cstdio> #include <algorithm> using namespace std; int n,m,x,y; char s; char l=’L’,r=’R’,u=’U’,d=’D’; int fx,fy,fl,an,vis; inline void op(char c) { putchar(c); putchar(‘n’); fflush(stdout); scanf(“%d%d”,&x,&y); if(x==fx&&y==fy)fl=1; } char ans; void dfs(int x,int y) { if(s==’*’||vis)return; vis=1; if(x==fx&&y==fy) { for(int i=1;i<=an;++i) op(ans); fl=1;return; } ++an; ans=u; dfs(x-1,y); if(fl)return; ans=d; dfs(x+1,y); if(fl)return; ans=l; dfs(x,y-1); if(fl)return; ans=r; dfs(x,y+1); if(fl)return; –an; } int...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!