Dashboard - Codeforces Round 886 (Div. 4) - Codeforces
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=3e5+10;
int b[N];
void solve()
{
int a[3];
for(int i=0;i<3;i++) cin>>a[i];
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(i!=j && a[i]+a[j]>=10){
cout<<"YES"<<endl;
return;
}
}
}
cout<<"NO"<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=3e5+10;
int b[N];
void solve()
{
int n;
cin>>n;
int a,b;
int maxx=0;
int nn=0;
for(int i=1;i<=n;i++)
{
cin>>a>>b;
if(a<=10 && b>maxx){
maxx=b;
nn=i;
}
}
cout<<nn<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=3e5+10;
int b[N];
void solve()
{
char a[10][10]={};
string s="";
for(int i=1;i<=8;i++){
for(int j=1;j<=8;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=8;i++){
for(int j=1;j<=8;j++){
if(a[i][j]!='.')
{
s+=a[i][j];
}
}
}
cout<<s<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}
?
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=2e5+10;
int a[N];
void solve()
{
int n,k;
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+1+n);
int maxx=1;
int ans=1;
for(int i=1,j=1;i<=n;i++){
if(i==1) continue;
else if(a[i]-a[i-1]<=k){
ans=i-j+1;
maxx=max(maxx,ans);
}else{
j=i;
}
}
cout<<n-maxx<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}
?
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
const int N=2e5+10;
int a[N];
int n,c;
bool check(int x)
{
int sum=0;
for(int i=1;i<=n;i++)
{
sum+=(a[i]+2*x)*(a[i]+2*x);
}
return sum>=c;
}
void solve()
{
cin>>n>>c;
for(int i=1;i<=n;i++) cin>>a[i];
int l=0,r=1e9/sqrt(n)+100;
while(l<r){
int mid=l+r>>1;
if(check(mid)) r=mid;
else l=mid+1;
}
cout<<l<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--) solve();
}
?
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n;
cin>>n;
vector<int> cnt(n+1),mx(n+1);
for(int i=0;i<n;i++){
int x;
cin>>x;
if(x<=n) cnt[x]++;
}
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j+=i){
mx[j]+=cnt[i];
}
}
cout<<*max_element(mx.begin(),mx.end())<<endl;
}
signed main()
{
int t=1;
cin>>t;
while(t--) solve();
}
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n;
cin>>n;
map<int,int> up,side,diag1,diag2;
int ans=0;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
up[x]++;
side[y]++;
diag1[x-y]++;
diag2[x+y]++;
}
for(auto x:up){
ans+=x.second*(x.second-1);
}
for(auto x:side){
ans+=x.second*(x.second-1);
}
for(auto x:diag1){
ans+=x.second*(x.second-1);
}
for(auto x:diag2){
ans+=x.second*(x.second-1);
}
cout<<ans<<endl;
}
signed main()
{
int t=1;
cin>>t;
while(t--) solve();
}
?
?
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define db double
#define pii pair<int,int>
vector<int> fa,v;
int n;
int find(int x)
{
if(x!=fa[x]){
int t=fa[x];
fa[x]=find(fa[x]);
v[x]+=v[t];
}
return fa[x];
}
void solve()
{
int n,m;
cin>>n>>m;
fa=vector<int>(n+1);
v=fa;
for(int i=1;i<=n;i++) fa[i]=i;
bool ok=true;
while(m--){
int a,b,d;
cin>>a>>b>>d;
int pa=find(a),pb=find(b);
if(pa!=pb){
fa[pa]=pb;
v[pa]=v[b]-v[a]+d;
}else{
if(v[a]-v[b]!=d){
ok=false;
//break;
}
}
}
if(ok) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>t;
while(t--) solve();
}