Codeforces Round #410 (Div. 2), problem: (D) Mike and distribution Solution In C/C++

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int b[maxn],n,flag=1,dp[maxn];
struct node
{
int id,x;
}a[maxn];
int cmp(node a,node b)
{
return a.x>b.x;
}
int main()
{
scanf(“%d”,&n);
for(int i=1;i<=n;i++)
{
scanf(“%d”,&a[i].x);
a[i].id=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++) scanf(“%d”,&b[i]);
int k=n/2+1;
printf(“%d\n%d\n”,k,a[1].id);
for(int i=2;i<=n;i+=2)
if(b[a[i].id]>b[a[i+1].id]) printf(“%d\n”,a[i].id);
else printf(“%d\n”,a[i+1].id);
return 0;
}

📦 Looking for Codeforces Round 410 Div Problem Mike? Check the best deals on Amazon.

🛒 Shop Codeforces Round 410 Div Problem Mike on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;
int b[maxn],n,flag=1,dp[maxn];
struct node
{
int id,x;
}a[maxn];
int cmp(node a,node b)
{
return a.x>b.x;
}
int main()
{
scanf(“%d”,&n);
for(int i=1;i<=n;i++)
{
scanf(“%d”,&a[i].x);
a[i].id=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++) scanf(“%d”,&b[i]);
int k=n/2+1;
printf(“%d\n%d\n”,k,a[1].id);
for(int i=2;i<=n;i+=2)
if(b[a[i].id]>b[a[i+1].id]) printf(“%d\n”,a[i].id);
else printf(“%d\n”,a[i+1].id);
return 0;
}

📦 Looking for Codeforces Round 410 Div Problem Mike? Check the best deals on Amazon.

🛒 Shop Codeforces Round 410 Div Problem Mike on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

Everything You Need to Know About Viral Kitchen Gadgets Right Now

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

What’s new in Gutenberg 24.0? (16 September)

The WordPress open-source community has officially unveiled Gutenberg 24.0, marking another milestone in the project's biweekly development cycle. This release brings a focused batch...

The Real Truth About Viral Kitchen Gadgets Before You Buy

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Viral Kitchen Gadgets through a proper 30-day real-world test, I can tell...

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!