Celebrating Black History Month:...
As February unfolds, so does the annual celebration of...
The Path to Self-Mastery:...
Embarking on a journey of self-mastery and breaking free...
Wizards of Waverly Place...
In a spellbinding announcement, Disney has officially revealed that...
Coachella 2024: Iconic headliners,...
Coachella Valley Music and Arts Festival, one of the...
2024 Taiwan Election: Pivotal...
As Taiwan gears up for its 2024 presidential election,...
Michael Strahan’s Daughter’s Medulloblastoma...
In a recent and heartbreaking revelation, Michael Strahan, former...
Michigan vs. Washington: The...
In a highly anticipated matchup, the 2024 National Championship...
Jason Kelce: Unmasking the...
In the world of professional football, where conformity often...
A Comprehensive Analysis of...
Boeing, a global aerospace giant, has long been a...
Unlocking Full-Stack Mastery: Web...
In the rapidly evolving landscape of technology, the demand...
Advertisement
C/C++
Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals), problem: (B) Black Square Solution In C/C++
#include <bits/stdc++.h>
using namespace std;
int n,m,maxx,minx=1e9,maxy,miny=1e9,T;
char a;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
cin>>a;
if(a=='B')T++,maxx=max(maxx,i),minx=min(minx,i),maxy=max(maxy,j),miny=min(miny,j);
}
if(!T)puts("1");
else{
int c=max(maxx-minx,maxy-miny)+1;
printf("%dn",(c>n||c>m)?-1:c*c-T);
}
}
C/C++
Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals), problem: (A) Restaurant Tables Solution in C/C++
#include <iostream>
using namespace std;
int main()
{
int n,a,b,bg=0,d=0,x;
cin>>n>>a>>b;
while(n--){
cin>>x;
if(x==1)
{if(a)a--;
else if(b)b--,bg++;
else if(bg)bg--;
else d++;
}
else {if(b)b--;else d+=2;
}
}
cout<<d;
}
C/C++
Codeforces Round #424 (Div. 1, rated, based on VK Cup Finals), problem: (E) Perpetual Motion Machine Solution In C/C++
#include <bits/stdc++.h>
using namespace std;
#define inf 1023456789
#define linf 1023456789123456789ll
#define pii pair<int,int>
#define pipii pair<int,...
C/C++
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...
Uncategorized
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++)...
Uncategorized
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...
C/C++
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...
C/C++
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...
Uncategorized
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 >>...
C/C++
Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals), problem: (A) Unimodal Array Solution In C/C++
#include<cstdio>
using namespace std;
int n,i,la,nw,fl,tp;
int main(){
for(scanf("%d%d",&n,&la);++i<n;la=nw,fl=tp)
if(scanf("%d",&nw),fl>(tp=(nw>la?0:(nw<la?2:1))))return puts("NO");
return puts("YES");
}
Uncategorized
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)...
C/C++
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...
Wizards of Waverly Place...
In a spellbinding announcement, Disney has officially revealed that...
Coachella 2024: Iconic headliners,...
Coachella Valley Music and Arts Festival, one of the...
2024 Taiwan Election: Pivotal...
As Taiwan gears up for its 2024 presidential election,...
Michael Strahan’s Daughter’s Medulloblastoma...
In a recent and heartbreaking revelation, Michael Strahan, former...
Michigan vs. Washington: The...
In a highly anticipated matchup, the 2024 National Championship...
Jason Kelce: Unmasking the...
In the world of professional football, where conformity often...
A Comprehensive Analysis of...
Boeing, a global aerospace giant, has long been a...
Unlocking Full-Stack Mastery: Web...
In the rapidly evolving landscape of technology, the demand...
Winter Skincare Essentials: Must-Have...
As winter sets in and the temperature drops, it's...
Morning Glow: DIY Beauty...
Unlocking the secret to radiant and glowing skin often...