1 / 7

USACO’s this weekend!

USACO’s this weekend!. Aren’t you EXCITED ?!? :D. PotW Solution (20 pts ). Scanner scan = new Scanner(System. in ); scan.useDelimiter ( "[^0-9]+" ); int n= scan.nextInt (); int preve =-1,c=0; for ( int i =1;i<= n;i ++) { int start = scan.nextInt ()*60 + scan.nextInt ();

kim
Download Presentation

USACO’s this weekend!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. USACO’s this weekend! Aren’t you EXCITED?!? :D

  2. PotW Solution (20 pts) Scanner scan = newScanner(System.in); scan.useDelimiter("[^0-9]+"); intn=scan.nextInt(); intpreve=-1,c=0; for(inti=1;i<=n;i++) { intstart = scan.nextInt()*60 + scan.nextInt(); intend = scan.nextInt()*60 + scan.nextInt(); if(start>=preve) { preve=end; c++; } } System.out.println(c);

  3. +15 Bonus Solution Scanner scan = newScanner(System.in); scan.useDelimiter("[^0-9]+"); intn=scan.nextInt(); int[] endt=newint[n+1],maxn=newint[n+1],maxt=newint[n+1]; endt[0]=-1; // add dummy segment maxn[0]=0; maxt[0]=0; for(inti=1;i<=n;i++) { intstart = scan.nextInt()*60 + scan.nextInt(); intend = scan.nextInt()*60 + scan.nextInt(); endt[i]=end; // save end intleft=0,right=i,mid; while(left+1 < right) { // binary search for last end landing before start mid = (left+right)/2; if(endt[mid]>start) right=mid; else left=mid; } // at end of binary search, "left" points to index of last end

  4. Bonus Solution (cont.) intcurn=maxn[left]+1; intcurt=maxt[left]+end-start; // memoize current values maxn[i]=maxn[i-1]; maxt[i]=maxt[i-1]; if(curn>maxn[i]) { maxn[i]=curn; // superior in terms of number maxt[i]=curt; } elseif(curn==maxn[i] && curt>maxt[i]) maxt[i]=curt; // tie, break tie by time } System.out.println(maxn[n]); System.out.println(maxt[n]);

  5. USACO Schedule! • Nov 11-14: November Contest • Dec 9-12: December Contest • Jan 6-9: January Contest • Feb 3-6: February Contest • Mar 2-5: March Contest • April: US Open • June: Training Camp • September: IOI 2012 in Milan, Italy • Also on lynbrookcs.com/usaco-schedule/

  6. USACO Tips/Reminders! • You should TAKE IT • usaco.org • You should PREPARE FOR IT • train.usaco.org • You should READ THE PROBLEM CAREFULLY • You should TEST YOUR PROGRAMS • Read the test data • Check the test data by hand • Check your algorithm by hand • Make your own test data • Test your program • Don’t waste your time on the wrong things! • You are allowed to copy code off the internet for algorithms you can’t remember • Cite your sources • General info about USACO on Oct. 3 meeting slides

  7. New PotW! • Nope! • Take the USACO instead! • Worth 5 points (if you actually submit something) • For credit, mark that you participated on the attendance sheet next meeting (or email us if you for some reason can’t make it to the next meeting)

More Related