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

#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;
}

#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;
}

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

The Ultimate Viral Kitchen Gadgets Guide You Didnt Know You Needed

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

We Tested Viral Kitchen Gadgets Here Is What You Must Know

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

BoA、日本デビュー25周年・「BoA the LIVE」20周年を彩る…横浜でツアーファイナル

Music icon BoA has officially wrapped up her monumental concert tour with an emotional and electrifying finale in Yokohama. The performance marked a historic...

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!