Sie sind auf Seite 1von 4

8/27/2015

ChefandWay|CodeChef

Hellosumer098!
AccountorLogOut

PRACTICE

COMPETE

DISCUSS

COMMUNITY

HELP

ABOUT

HomePractice(school)ChefandWay

ChefandWay
Problemcode:CHRL4
Like

ALLSUBMISSIONS

MYSUBMISSIONS

SUBMIT

Share 18peoplelikethis.Bethefirstofyourfriends.

Allsubmissionsforthisproblemareavailable.

SUCCESSFULSUBMISSIONS

ReadproblemsstatementsinRussianalso.
Score Mem

Lang

asish7594

100.000 4.3M

C++4.3.2

View

Chefwantstogettohomeinsuchawaythattheproductofallthevisitedstreets'specialnumbersis
minimal(includingthefirstandtheNthstreet).Please,helphimtofindsuchaproduct.

kp1kp0102810

100.000 4.3M

C++4.3.2

View

Input

prateekjain348

100.000 4.3M

C++4.3.2

View

quochuya

100.000 4.3M

C++4.3.2

View

ari15nitmas

100.000 4.3M

C++4.3.2

View

tushar9989

100.000 4.3M

C++4.3.2

View

radha_123

100.000 4.3M

C++4.3.2

View

chandradeep01

100.000 4.3M

C++4.3.2

View

sai5657

100.000 4.3M

C++4.3.2

View

a2hksy

100.000 4.3M

C++4.3.2

View

mom12

100.000 4.3M

C++4.3.2

View

sachdevarockz

100.000 4.3M

C++4.3.2

View

Aftervisitingachildhoodfriend,Chefwantstogetbacktohishome.Friendlivesatthefirststreet,and
ChefhimselflivesattheNth(andthelast)street.Theircityisabitspecial:youcanmovefromtheXth
streettotheYthstreetifandonlyif1<=YX<=K,whereKistheintegervaluethatisgiventoyou.

ThefirstlineofinputconsistsoftwointegernumbersNandKthenumberofstreetsandthevalueof
Krespectively.ThesecondlineconsistofNnumbersA1 ,A2 ,...,ANrespectively,whereAiequalsto
thespecialnumberoftheithstreet.

Output
Pleaseoutputthevalueoftheminimalpossibleproduct,modulo1000000007.

Constraints

User

Solution

1N10^5
1Ai10^5
1KN

Example
Input:
42
1234.
Output:
8

Scoring
1of17

Subtask1(30points):N<=80
Subtask2(70points):Seetheconstraints.
Author:

furko

Tester:

xcwgf666

Editorial

http://discuss.codechef.com/problems/CHRL4

Tags

dpeasymediumfurkoltime08

DateAdded: 21012014
TimeLimit:

1sec

SourceLimit: 50000Bytes

Languages:

ADA,ASM,BASH,BF,C,C99strict,CAML,CLOJ,CLPS,CPP4.3.2,CPP4.9.2,CPP14,
CS2,D,ERL,FORT,FS,GO,HASK,ICK,ICON,JAVA,JS,LISPclisp,LISPsbcl,LUA,
NEM,NICE,NODEJS,PASfpc,PASgpc,PERL,PERL6,PHP,PIKE,PRLG,PYTH,
PYTH3.1.2,RUBY,SCALA,SCMguile,SCMqobi,ST,TCL,TEXT,WSPC

SUBMIT

Comments
code_hard123@11Jul201505:26PM

https://www.codechef.com/problems/CHRL4

HELP

Program should read from standard input and write to


standardoutput.After you submit a solution you can see
yourresultsbyclickingonthe[MySubmissions]tabonthe
problempage.Belowarethepossibleresults:

Accepted Your program ran successfully and


gave a correct answer. If there is a score for the
problem, this will be displayed in parenthesis next to
thecheckmark.
Time Limit Exceeded Your program was
compiledsuccessfully,butitdidn'tstopbeforetimelimit.
Tryoptimizingyourapproach.
Wrong Answer Your program compiled and ran
succesfully but the output did not match the expected
output.
Runtime Error

Your code compiled and ran but

1/4

8/27/2015

ChefandWay|CodeChef
dp[i]=min(dp[i],(dp[j]*a[i])%mod)foralljsuchthatij>=1&&ij<=k.whydoesn'tthisworkshere?

deepakky25@22Jul201512:55AM
whtswrongwiththisintk,i,nscanf("%d%d",&n,&k)inta[n]for(i=0i=curri)if(min>a[i]) { min=a[i]
minx=i+1}curr=minxpro=pro*a[curr1]}printf("%dn",pro)

encountered an error. The most common reasons are


using too much memory or dividing by zero. For the
specificerrorcodesseethehelpsection.
Compilation Error Your code was unable to
compile. When you see this icon, click on it for more
information.
If you are still having problems, see a sample solution
here.

ahothman@24Jul201506:40PM
itismyfirsttimeinthissite,andidon'tknowhowtosubmitmysolutionaswheniclickonsubmit
button,itrefreshthepagebutnothinghappens

master_86@28Jul201502:39AM
runtimeerror:(

enobil@30Jul201504:05PM
Ithinkanswerfor@code_hard123and@deeppakky25isbecausethealgorithmyoumentioned
hasO(N*K)timewhichisO(N^2)andalsologarithmoperationmaytakesomeextratime,thenN^2
maynotbeacceptableinthissituation.IkeepgettingTLE(1.01)fortask6forIguessthatreason.

medyas@3Aug201503:44PM
Ithinktheirisaproblem..EveryoneisgettingWA

ashoksayzz@3Aug201510:43PM
runtimeerror:(

mdifelice@6Aug201502:45AM
Itwouldbenicethatrathertoshowingthesolutionsyou'llgiveusaccesstothetestcases.Ithink
thiswaywecanlearnbetterwhyoursolutionsdonotwork.

thinkerbof@9Aug201501:15AM
WeneedformoretestcasesCodeChef

piyush88@9Aug201511:57AM
howcanchecktestcaseinputandoutput?

pkedia46@14Aug201512:14AM
cananyoneexplainmethisques?

hit1bit10_3134@15Aug201507:29PM
Please...alsogiveexplanationfortestcaseslikeHackerrank.

moazzamhussain@16Aug201509:24PM
somebodyhelpme.whatiswrongwithmycode?https://www.codechef.com/viewsolution/7831882

akif_islam@20Aug201512:45AM
I can't understand the problems. :( I need some inspiration and friends. How can I join in
programmingVirtualWorld?

vvikass@21Aug201511:18AM
smjniayaqustionexplainitbitereasy

vvikass@21Aug201511:21AM
yoveryajibbbbbbbbqustion

https://www.codechef.com/problems/CHRL4

2/4

8/27/2015

ChefandWay|CodeChef

ektaluv@21Aug201511:22AM
vikasitssosimplewhydontuunderstandingthis

vvikass@21Aug201511:23AM
solutionbejphiraurpehlephnbndkr

arpitmittal555@21Aug201503:54PM
whatisthemeaningof..modulo100000007?

evellonin@21Aug201506:42PM
@ arpitmittal555 The numbers in subtask 2 can get pretty big. Modulo 100000007 keeps them
smallenoughtofitin32bitint

hitman333@21Aug201507:07PM
howtheoutputforthegiveninputsis8...........plzzzzexplain

hitman333@21Aug201507:07PM
howtheoutputforthegiveninputsis8...........plzzzzexplain

pindikanti@24Aug201509:00PM
Wrong answer, I have tried a number of test cases all are giving perfect answers (even for big
numbersasN=50).isthereanyspecificcasewhichIammissing?

rishabh1310@25Aug201504:38PM
cansomeoneexplaintheoutput.

Needhelp?Postacomment.Butbeforethatpleasespareamomenttoreadtheguidelines.
Yourname:
sumer098
Comment:*

Save

CodeChefisanoncommercialcompetitiveprogrammingcommunity

AboutCodeChef AboutDirecti CEO'sCorner CProgramming ProgrammingLanguages ContactUs


2009DirectiGroup.AllRightsReserved.CodeChefusesSPOJbySphereResearchLabs
Inordertoreportcopyrightviolationsofanykind,sendinanemailtocopyright@codechef.com

Thetimenowis:12:50:32AM
YourIp:125.20.9.248

CodeChefAPlatformforAspiringProgrammers
CodeChefwascreatedasaplatformtohelpprogrammersmakeitbigintheworldofalgorithms,computerprogrammingandprogrammingcontests.AtCodeChefweworkhardto
revivethegeekinyoubyhostingaprogrammingcontestatthestartofthemonthandanothersmallerprogrammingchallengeinthemiddleofthemonth.Wealsoaimtohave
trainingsessionsanddiscussionsrelatedtoalgorithms,binarysearch,technicalitieslikearraysizeandthelikes.Apartfromprovidingaplatformforprogrammingcompetitions,
CodeChefalsohasvariousalgorithmtutorialsandforumdiscussionstohelpthosewhoarenewtotheworldofcomputerprogramming.

PracticeSectionAPlacetohoneyour'ComputerProgrammingSkills'
Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+
programminglanguages.Preparingforcodingcontestswereneverthismuchfun!Receivepoints,andmoveupthroughtheCodeChefranks.Useourpracticesectiontobetterprepare
yourselfforthemultipleprogrammingchallengesthattakeplacethroughoutthemonthonCodeChef.

CompeteMonthlyProgrammingContestsandCookoffs
Hereiswhereyoucanshowoffyourcomputerprogrammingskills.Takepartinour10daylongmonthlycodingcontestandtheshorterformatCookoffcodingcontest.Putyourself
upforrecognitionandwingreatprizes.OurprogrammingcontestshaveprizesworthuptoINR20,000(forIndianCommunity),$700(forGlobalCommunity)andlotsmoreCodeChef
goodiesupforgrabs.

https://www.codechef.com/problems/CHRL4

3/4

8/27/2015

ChefandWay|CodeChef

ProgrammingTools

PracticeProblems

Initiatives

OnlineIDE

Easy

GoforGold

UpcomingCodingContests

Medium

CodeChefforSchools

ContestHosting

Hard

CampusChapters

ProblemSetting

Challenge

CodeChefTutorials

Peer

CodeChefWiki

School
FAQ's

https://www.codechef.com/problems/CHRL4

4/4

Das könnte Ihnen auch gefallen