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

Advertisement

spot_img

Tsai partner on sports...

When billionaire Joe Tsai initially acquired a 49 percent...

Is Viral Kitchen Gadgets...

📢 As an Amazon Associate, I earn from qualifying...

Japan protests as Putin...

Diplomatic tensions between Tokyo and Moscow have sharply escalated...

Is Viral Kitchen Gadgets...

📢 As an Amazon Associate, I earn from qualifying...

Stop Buying Cheap Alternatives...

📢 As an Amazon Associate, I earn from qualifying...

Why Viral Kitchen Gadgets...

📢 As an Amazon Associate, I earn from qualifying...

Tsai partner on sports as an asset class and bigger business behind Nets

When billionaire Joe Tsai initially acquired a 49 percent stake in the Brooklyn Nets in 2017 before taking complete ownership, the transaction signaled much...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

📢 As an Amazon Associate, I earn from qualifying purchases.Most products in this category disappoint within weeks. Cheap materials, vague instructions, and results that...

Japan protests as Putin orders takeover of Japan Tobacco’s Russia unit

Diplomatic tensions between Tokyo and Moscow have sharply escalated following Russian President Vladimir Putin's decision to order the takeover of Japan Tobacco International's operations...

Is Viral Kitchen Gadgets Worth Your Money Here Is Our Full Review

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

Stop Buying Cheap Alternatives This Viral Kitchen Gadgets Is the Real Deal

📢 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...

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

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

Why Viral Kitchen Gadgets Is Currently Breaking the Internet

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

How Viral Kitchen Gadgets Is Quietly Changing the Game

📢 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...

Science of a city: The maths, physics, ecology & psychology of urban life

When we discuss the world’s greatest metropolises, the conversation almost invariably revolves around politics, zoning regulations, and economic indicators. Yet, beneath the concrete grid...