Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <algorithm>
- #include <fstream>
- #include <set>
- #include <string>
- #include <cmath>
- #include <list>
- #include <deque>
- #include <iterator>
- #include <time.h>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- using ll = long long;
- struct comp
- {
- int price;
- string name;
- string country;
- string date;
- };
- void input(comp *a)
- {
- cin >> a->name;
- cin >> a->country;
- cin >> a->price;
- cin >> a->date;
- }
- int middle(comp **a, int sum,int n)
- {
- for (int i = 0; i < n; i++)
- {
- sum += a[i]->price;
- }
- return sum;
- }
- void highest(comp **a, int n)
- {
- string str = a[0]->country;
- string ans=a[0]->name;
- int high=a[0]->price;
- bool check = false;
- for (int i = 0; i < n; i++)
- {
- while (i < n&&str == a[i]->country)
- {
- check = true;
- if (high < a[i]->price)
- {
- ans = a[i]->name;
- high = a[i]->price;
- }
- i++;
- }
- if (check)
- {
- check = false;
- i--;
- }
- }
- }
- int main() {
- ifstream cin("input.txt");
- int n,sum=0;
- scanf("%d", &n);
- comp** a = (comp**)malloc((n + 1)*sizeof(comp*));
- for (int i = 0; i < n; i++)
- {
- a[i] = (comp*)malloc(sizeof(comp));
- input(a[i]);
- }
- sort(a->country.begin(), a->country.end());
- highest(a,n);
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement