PAT Basic 1032
生活随笔
收集整理的這篇文章主要介紹了
PAT Basic 1032
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1032?挖掘機(jī)技術(shù)哪家強(qiáng)?(20 分)
注意紅色標(biāo)記,想當(dāng)然地認(rèn)為了循環(huán)范圍,實際可以取值到n
數(shù)組范圍也應(yīng)當(dāng)定義到a[100001]
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#define max 100001
#define debug 0
using namespace std;
int main() {
#if debug
?? ?freopen("in.txt", "r", stdin);
#endif
?? ?int a[max] = {0}, n = 0, temp = 0, score;
?? ?cin >> n;
?? ?for (int i = 0; i < n; i++)
?? ?{
?? ??? ?cin >> temp>>score;
?? ??? ?a[temp] += score;
?? ?}
?? ?int ma = 0;
?? ?for (int i = 1; i <=n; i++)
?? ?{
?? ??? ?if (a[ma] < a[i])
?? ??? ?{
?? ??? ??? ?ma = i;
?? ??? ?}
?? ?}
?? ?cout << ma << ' ' << a[ma];
#if debug
?? ?freopen("CON", "r", stdin);
#endif
?? ?return 0;
}
為了用事實說明挖掘機(jī)技術(shù)到底哪家強(qiáng),PAT 組織了一場挖掘機(jī)技能大賽?,F(xiàn)請你根據(jù)比賽結(jié)果統(tǒng)計出技術(shù)最強(qiáng)的那個學(xué)校。
輸入格式:
輸入在第 1 行給出不超過?10?5???的正整數(shù)?N,即參賽人數(shù)。隨后?N?行,每行給出一位參賽者的信息和成績,包括其所代表的學(xué)校的編號(從 1 開始連續(xù)編號)、及其比賽成績(百分制),中間以空格分隔。
輸出格式:
在一行中給出總得分最高的學(xué)校的編號、及其總分,中間以空格分隔。題目保證答案唯一,沒有并列。
輸入樣例:
6 3 65 2 80 1 100 2 70 3 40 3 0輸出樣例:
2 150注意紅色標(biāo)記,想當(dāng)然地認(rèn)為了循環(huán)范圍,實際可以取值到n
數(shù)組范圍也應(yīng)當(dāng)定義到a[100001]
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#define max 100001
#define debug 0
using namespace std;
int main() {
#if debug
?? ?freopen("in.txt", "r", stdin);
#endif
?? ?int a[max] = {0}, n = 0, temp = 0, score;
?? ?cin >> n;
?? ?for (int i = 0; i < n; i++)
?? ?{
?? ??? ?cin >> temp>>score;
?? ??? ?a[temp] += score;
?? ?}
?? ?int ma = 0;
?? ?for (int i = 1; i <=n; i++)
?? ?{
?? ??? ?if (a[ma] < a[i])
?? ??? ?{
?? ??? ??? ?ma = i;
?? ??? ?}
?? ?}
?? ?cout << ma << ' ' << a[ma];
#if debug
?? ?freopen("CON", "r", stdin);
#endif
?? ?return 0;
}
轉(zhuǎn)載于:https://www.cnblogs.com/lxzbky/p/10507431.html
總結(jié)
以上是生活随笔為你收集整理的PAT Basic 1032的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [CTSC2017]吉夫特
- 下一篇: Codeforces 868F Yet