poj 2371 Questions and answers
生活随笔
收集整理的這篇文章主要介紹了
poj 2371 Questions and answers
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
題目鏈接:http://poj.org/problem?id=2371
題意:前面給出N和N個(gè)數(shù),中間一串字符串(分割用),后面給出M和M個(gè)詢問(wèn),問(wèn)第I小的數(shù)字是多少。
分析:水。。。直接sort一下,然后輸出第I-1個(gè)就好(下標(biāo)從0開(kāi)始)。
代碼:
#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]);} } View Code?
轉(zhuǎn)載于:https://www.cnblogs.com/wwdf/p/5781469.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的poj 2371 Questions and answers的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: linux 完全卸载软件方法
- 下一篇: LoadRunner参数包含逗号