BestCoder36 1002.Gunner Problem Solving report

Source: Internet
Author: User

Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5199

Given the height of the bird in the tree, and the height of the shot, ask each shot to shoot the number of birds

In the game when this code is AC, to Hangzhou Electric has been the tle .... Hope that the heart of the people can point to the guidance. Busy in Snatch also ~ ~ ~

  

1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cstdlib>5#include <vector>6#include <algorithm>7 using namespacestd;8 9 Const intMAXN = 1e6 +5;Ten intVIS[MAXN]; Onevector<int>:: iterator P1, p2; Avector<int>h; -  - intMain () the { - #ifndef Online_judge -Freopen ("In.txt","R", stdin); -     #endif //Online_judge +  -     intN, M, q, HI; +      while(SCANF ("%d%d", &n, &m)! =EOF) { A h.clear (); at          for(inti =0; I < n; i++) { -scanf"%d", &hi); - h.push_back (HI); -         } -  - sort (H.begin (), H.end ()); inmemset (Vis,0,sizeof(Vis)); -          for(inti =0; I < m; i++) { toscanf"%d", &q); +P1 =Lower_bound (H.begin (), H.end (), q); -P2 =Upper_bound (H.begin (), H.end (), q); the             intpos = P1-H.begin (); *             intPOS1 = P2-H.begin (); $             if(POS1 <= n && pos <= n && pos1! =POS) {Panax Notoginseng                 intT1 = H[pos], t2 =H[POS1]; -                 if(T1 = =q) { the                     if(!Vis[pos]) { +printf"%d\n", pos1-POS); AVis[pos] =1; the                     } +                     Else -printf"0\n"); $                 } $             } -             Else -printf"0\n"); the         } -     }Wuyi     return 0; the}

BestCoder36 1002.Gunner Problem Solving report

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.