poj 2371 Questions and answers

题目链接:http://poj.org/problem?id=2371

题意:前面给出N和N个数,中间一串字符串(分割用),后面给出M和M个询问,问第I小的数字是多少。

分析:水。。。直接sort一下,然后输出第I-1个就好(下标从0开始)。

代码:

#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long ll;
#define Max(a,b) (a>b)?a:b
#define lowbit(x) x&(-x)
int n,a[1000005];
int main()
{

    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    char s[105];
    scanf("%s",s);
    int m;
    scanf("%d",&m);
    while(m--)
    {
        scanf("%d",&n);
        printf("%d\n",a[n-1]);
    }
}

时间: 2024-10-27 07:28:57

poj 2371 Questions and answers的相关文章

iOS interview questions and Answers

http://gksanthoshbe.blogspot.com/2013/03/ios-interview-questions-and-answers.html 1-How would you create your own custom view? By Subclassing the UIView class. 2-Whats fast enumeration? Fast enumeration is a language feature that allows you to enumer

69 Spring Interview Questions and Answers – The ULTIMATE List--reference

This is a summary of some of the most important questions concerning the Spring Framework, that you may be asked to answer in an interview or in an interview test procedure! There is no need to worry for your next interview test, because Java Code Ge

Poj_2371 Questions and answers

题目链接:http://poj.org/problem?id=2371 思路: 使用计数排序或其他时间复杂度为O( log N )的排序. 代码: #include <iostream> #include <algorithm> #define MAX_N ( 100000 + 10 ) using namespace std; int A[MAX_N]; int main() { int n, k, i, j; char Tmp[5]; cin >> n; for (

Foxwell GT80 / GT80 Plus Frequently questions and answers

This post collect all of Foxwell GT80 / GT80 Plus questions and engineer answers from foxwellshop customers, hope it enlighten others who are interested in this tool. BTW, Foxwell GT80 and GT80 Plus share the same function and vehicle coverage, the o

300+ Manual Testing and Selenium Interview Questions and Answers

Manual testing is a logical approach and automation testing complements it. So both are mandatory and required to ensure the quality. To test and prepare for the testing and automation interviews, enough material is provided here. 300+ testing and au

Microsoft Azure AZ-102 Exam Questions And Answers

The Microsoft Azure Administrator Certification Transition works as a descriptive program that intended to improve the selection, delivery, maintenance and planning of IT products and services with a business enterprise. Azure Administrator Associate

Quick Questions and Answers on Physics

1. Is Liouville Theorem applicable for dissipative systems? Yes. As long as the system can be described by a Hamiltonian. ref: http://physics.stackexchange.com/a/111026/43643

【译】Core Java Questions and Answers【1-33】

前言 译文链接:http://www.journaldev.com/2366/core-java-interview-questions-and-answers Java 8有哪些重要的特性 Java 8发布于2014年3月,这块内容在Java面试中非常常见.如果你能清晰的回答这方面的问题,说明you are not out,喜欢学习最新的技术.Java 8是继Java 5的注解和泛型之后所做的最大的改动,主要的新特性如下: 1.接口支持静态方法和默认方法 2.函数式接口和Lambda表达式 3

[转]Blue Prism Interview Questions and Answers

本文转自:https://www.rpatraining.co.in/blue-prism-interview-questions/ What is a Visual Business Object? The role of a VBO is to act as an adapter to the user interface of a specific application. To accomplish this,each VBO has three main parts: A connec