PKU 1065 PKU 1548

Source: Internet
Author: User

The two questionsCodeBasically the same as PKU 3636

The main difference is that the second element is also sorted in ascending order. Because the first element is the same, the second element can be added in ascending order without adding a bucket again.

Therefore, an equal sign must be removed from the next judgment condition.

Pku1065

# Include <iostream> # include <algorithm> using namespace STD; struct node {int H, W; bool operator <(node A) {if (. W = W) return H <. h; return W <. W ;}} ele [5010]; int A [5010]; int main () {int cas, N; CIN> CAS; while (CAS --) {CIN> N; For (INT I = 0; I <n; I ++) CIN> ele [I]. w> ele [I]. h; sort (Ele, ELE + n); int q = 0; For (INT I = 0; I <n; I ++) {int L = 0, R = Q; while (L <r) {int M = (R + l)/2; if (a [m]> ele [I]. h) L = m + 1; else r = m;} A [l] = E Le [I]. h; // A [] Save the boundary value of each bucket q + = L = Q; // if no bucket is found, add a new bucket. } Cout <q <Endl;} return 0 ;}

PKU 1548

#include 
  
   #include 
   
     using namespace STD; struct node {int X, Y; friend bool operator <(const node & A, const node & B) {if (. X = B. x) return. Y 
    
      A> B & (! =-1 | B! =-1) {if (a = 0 & B = 0) {sort (Ele, ELE + n); int L, R, Q = 0; for (INT I = 0; I 
     
       ele [I]. y) L = m + 1; else r = m;} f [l] = ele [I]. y; q + = L = Q ;}cout 
      
     
    
   
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.