Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could you please help identify what is wrong with my code? The output is not as instructed and I am stuck on this question. Thank

Could you please help identify what is wrong with my code? The output is not as instructed and I am stuck on this question. Thank you.

#include

using namespace std;

int main()

{

int n;

cin>>n;

int t[n],k[n],a[n][300005],nationality[300005]={0};

int z=0,j=0;

for(int i=0;i

{

cin>>t[i];

cin>>k[i];

for(int j=0;j

{

cin>>a[i][j];

nationality[a[i][j]-1]++;

}

while(t[i]-t[j]>=86400)

{

for(int x=0;x

{

nationality[a[j][x]-1]--;

}

j++;

}

int count=0;

for(int z=0;z

{

if(nationality[z]>0)

{

count++;

}

}

cout

}

return 0;

}

image text in transcribedimage text in transcribed
Description Victoria Harbour in Hong Kong has many busy ports and piers for all kinds of usage. For example, Kai Tak Cruise Terminal always welcomes large cruises with people from around the world. As a customs officer working in Kai Tak Cruise Terminal, Kyaru needs to record the information of all the cruises arrived and the passengers they carry. Specifically, for the ith arrived cruise, she records it- as the time it arrived, kg as the number of passengers on board, and :15le S j S 143,-) as the nationality of each passengers. One day, she was asked that for each of the cruises, she needs to count the number of different nationalities of all the passengers passing the customs within 24 hours(86400 seconds) before its arrival (include passengers on itself) (the time gap between one's cruise arriving at the terminal and him passing the customs is ignored). Since there're too many records on her hand, she turned to you for help. Formally, you need to check 11 records. For the ith record, you should count the number of different numbers appeared among all mpg fulfilling ti 86400

<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions