Tag: Codeforces.com

Codeforces Round #473 (Div. 2), problem: (F) Mahmoud and Ehab and yet another xor task Solution In C/C++

#include<bits/stdc++.h> #define LL long long using namespace std; const int maxn = 1e5+5; const int mod =1e9+7; typedef pair<int,int>pii; int a; int b; int ans; int...

Codeforces Round #473 (Div. 2), problem: (D) Mahmoud and Ehab and another array construction task Solution In C/C++

#include<stdio.h> int vi={0}; int main(void) { int n, a, now = 2; int ans; scanf("%d", &n); int flag = 0; int i,j,k; for (i = 1;...

Codeforces Round #473 (Div. 2), problem: (C) Mahmoud and Ehab and the wrong algorithm Solution In C/C++

#include<stdio.h> int main(){ int n; scanf("%d",&n); if(n <= 5) printf("-1n"); else{ printf("1 2n2 3n2 4n"); for(int i = 5;i <= n;i++) printf("1 %dn",i); } for(int i = 2;i...

Codeforces Round #473 (Div. 2), problem: (B) Mahmoud and Ehab and the message Solution In C/C++

#include<bits/stdc++.h> using namespace std; map<string,int> ms; string str; int arr,temp,mn; int main() { int n,k,m;cin>>n>>k>>m; for(int i=1;i<=n;i++)cin>>str,ms=i; for(int i=1;i<=n;i++)cin>>arr,mn=1e9+7; for(int i=1,j;i<=k;i++) { int x;cin>>x; while(x--)cin>>j,temp=i,mn=min(mn,arr); } unsigned long long res=0; while(cin>>str){res+=mn]];} return cout<<res<<"n",0; }

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

#include<cstdio> #include<cstring> #include<algorithm> #include<set> using namespace std; int n,k; struct node { int maxx,minn,sz; node() { int x;sz = 1; for(int i = 1; i <= k ; i...

Codeforces Round #443 (Div. 2), problem: (D) Teams Formation Solution In C/C++

#include <stdio.h> struct node { __int64 ans,num; }s; int main() { int n,k,m; while(~scanf("%d%d%d",&n,&k,&m)) { scanf("%I64d",&s.num); s.ans=1; int len=1; for(int i=1;i<n;i++) { int x; scanf("%d",&x); if(x==s.num) { s.ans++; if(s.ans==k) { s.ans=0; len--; } } else { s.num=x; s.ans=1; len++; } } int l=0,r=len-1; __int64 sum=0; while(s.num==s.num&&r>l) { if((s.ans+s.ans)>=k)sum+=k; s.ans=(s.ans+s.ans)%k; s.ans=0; if(s.ans!=0) { break; } l++,r--; } if(l==r) { if((s.ans*m)%k==0)sum=0; else sum+=((s.ans*m)%k); } else { for(int i=l;i<=r;i++) { sum+=(s.ans*m); } } printf("%I64dn",sum); } return 0; }

Codeforces Round #443 (Div. 2), problem: (C) Short Program Solution In C/C++

#include <iostream> using namespace std; const int maxn = 5e5; int n, x, a = 0, b = 1023, y; char...

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++) ...

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!