国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

1083 List Grades (PAT甲級)

這篇具有很好參考價值的文章主要介紹了1083 List Grades (PAT甲級)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

#include <iostream>
#include <vector>
#include <algorithm>

struct node{
    std::string name;
    std::string id;
    int grade;
};

bool cmp(node &a, node &b){
    return a.grade > b.grade;
}

int main(){
    int N, g1, g2, cnt;
    std::vector<node> vec;
    std::cin >> N;
    vec.resize(N);
    for(int i = 0; i < N; ++i){
        std::cin >> vec[i].name >> vec[i].id >> vec[i].grade;
    }
    std::cin >> g1 >> g2;
    sort(vec.begin(), vec.end(), cmp);
    cnt = 0;
    for(int i = 0; i < N; ++i){
        if(vec[i].grade <= g2 && vec[i].grade >= g1){
            std::cout << vec[i].name << " " << vec[i].id << std::endl;
            ++cnt;
        }
        if(vec[i].grade < g1){
            break;
        }
    }
    if(cnt == 0){
        std::cout << "NONE";
    }
    return 0;
}

題目如下:

Given a list of?N?student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the grades are in a given interval.

Input Specification:

Each input file contains one test case. Each case is given in the following format:

N
name[1] ID[1] grade[1]
name[2] ID[2] grade[2]
... ...
name[N] ID[N] grade[N]
grade1 grade2

where?name[i]?and?ID[i]?are strings of no more than 10 characters with no space,?grade[i]?is an integer in [0, 100],?grade1?and?grade2?are the boundaries of the grade's interval. It is guaranteed that all the grades are?distinct.

Output Specification:

For each test case you should output the student records of which the grades are in the given interval [grade1,?grade2] and are in non-increasing order. Each student record occupies a line with the student's name and ID, separated by one space. If there is no student's grade in that interval, output?NONE?instead.文章來源地址http://www.zghlxwxcb.cn/news/detail-480428.html

Sample Input 1:

4
Tom CS000001 59
Joe Math990112 89
Mike CS991301 100
Mary EE990830 95
60 100

Sample Output 1:

Mike CS991301
Mary EE990830
Joe Math990112

Sample Input 2:

2
Jean AA980920 60
Ann CS01 80
90 95

Sample Output 2:

NONE

到了這里,關(guān)于1083 List Grades (PAT甲級)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • PAT 甲級【1010 Radix】

    PAT 甲級【1010 Radix】

    本題范圍long型(35)^10 枚舉radix范圍上限pow(n/a0,1/m)上,考慮上限加1.范圍較大。使用二分查找枚舉 代碼如下 本頁面將簡要介紹二分查找,由二分法衍生的三分法以及二分答案。 二分查找(英語:binary search),也稱折半搜索(英語:half-interval search)、對數(shù)搜索(英語:logar

    2024年02月08日
    瀏覽(20)
  • PAT 甲級考試【1003 Emergency】

    PAT 甲級考試【1003 Emergency】

    題目: As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead

    2024年02月08日
    瀏覽(93)
  • pat甲級 1022 Digital Library

    A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query from a reader, you are supposed to output the resulting books, sorted in increasing order of their ID\\\'s. Input Specification: Each inp

    2024年04月15日
    瀏覽(24)
  • 1111 Online Map (PAT甲級)

    這道題我讀題不仔細(xì)導(dǎo)致踩了個大坑,一個測試點過不了卡了好幾個小時:第二個dijkstra算法中,題目要求是“In case the fastest path is not unique, output the one that passes through the fewest intersections”,我卻想當(dāng)然地認(rèn)為在fastest path is not unique的時候,判斷標(biāo)準(zhǔn)是最短距離…… Input our

    2024年02月07日
    瀏覽(16)
  • 菜鳥記錄PAT甲級1003--Emergency

    菜鳥記錄PAT甲級1003--Emergency

    久違的PAT,由于考研408數(shù)據(jù)結(jié)構(gòu)中有一定需要,同時也是對先前所遺留的競賽遺憾進(jìn)行一定彌補 ,再次繼續(xù)PAT甲級1003.。 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l

    2023年04月13日
    瀏覽(97)
  • PAT甲級圖論相關(guān)題目

    PAT甲級圖論相關(guān)題目

    PAT甲級圖論相關(guān)題目: 分?jǐn)?shù) 25 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some o

    2024年01月21日
    瀏覽(23)
  • 1021 Deepest Root (PAT甲級)

    1021. Deepest Root (25)-PAT甲級真題(圖的遍歷,dfs,連通分量的個數(shù))_柳婼的博客-CSDN博客 柳婼的解法在這里,兩次dfs,還是挺好玩的。 我的解法比較暴力,就是先用并查集算連通分量(這個其實還是dfs來算會更方便),如果只有一個連通分量,那deepest root一定在僅有一條arc的

    2024年02月15日
    瀏覽(16)
  • 1114 Family Property (PAT甲級)

    This time, you are supposed to help us collect the data for family-owned property. Given each person\\\'s family members, and the estate(房產(chǎn))info under his/her own name, we need to know the size of each family, and the average area and number of sets of their real estate. Input Specification: Each input file contains one test case. For each case, the fir

    2024年02月06日
    瀏覽(19)
  • 1072 Gas Station (PAT甲級)

    A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map of the city and several candidate locations for the gas station, you are supposed to give the best recommendatio

    2024年02月09日
    瀏覽(22)
  • PAT 甲級【1007 Maximum Subsequence Sum】

    本題是考察動態(tài)規(guī)劃與java的快速輸入: max[i]表示第i個結(jié)尾的最大的連續(xù)子串和。b begin[i]表示第[begin[i],i]為最大和的開始位置 超時代碼: 未超時: 能用動態(tài)規(guī)劃解決的問題,需要滿足三個條件:最優(yōu)子結(jié)構(gòu),無后效性和子問題重疊。 具有最優(yōu)子結(jié)構(gòu)也可能是適合用貪心的

    2024年02月08日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包