Submission #894897

# Submission time Handle Problem Language Result Execution time Memory
894897 2023-12-29T07:36:39 Z 3as8 Med (COCI22_med) C++14
50 / 50
117 ms 508 KB
#include <bits/stdc++.h>

#define ll long long
#define endl "\n"
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);

#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)

using namespace std;

struct node {
    ll x;
    string name;
};


bool cmp(node a, node b) {
    if(a.x == b.x) {
        return string(a.name) < string(b.name);
    }

    return a.x > b.x;
}

ll getMx( vector<node> arr, ll j) {

    arr[j].x += 500;
    string name = arr[j].name;

    sort(arr.begin(), arr.end(), cmp);
    for(int i = 0; i < arr.size(); i++) {
        if(arr[i].name == name) return i + 1;
    }

    return -1;
}


ll getMin( vector<node> arr, ll j) {

    for(int i = 0; i < arr.size(); i++) {
        if(i == j) continue;
        arr[i].x += 500;
    }

    string name = arr[j].name;

    sort(arr.begin(), arr.end(), cmp);
    for(int i = 0; i < arr.size(); i++) {
        if(arr[i].name == name) return i + 1;
    }

    return -1;
}

void solve(ll _) {


    ll n; cin>>n;
    vector<node> arr(n);

    for(int i = 0; i < n; i++) {
        cin>>arr[i].name;
        ll sum = 0;
        for(int j = 0; j < 5; j++) {
            ll x; cin>>x;
            sum += x;
        }

        arr[i].x = sum;
    }

    
    for(int i = 0; i < n; i++) {
        cout<<getMx(arr, i)<<" "<<getMin(arr, i)<<endl;
    }
}

int main() {

    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);

    ll t = 0;  solve(t);
}

Compilation message

Main.cpp: In function 'long long int getMx(std::vector<node>, long long int)':
Main.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0; i < arr.size(); i++) {
      |                    ~~^~~~~~~~~~~~
Main.cpp: In function 'long long int getMin(std::vector<node>, long long int)':
Main.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 0; i < arr.size(); i++) {
      |                    ~~^~~~~~~~~~~~
Main.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for(int i = 0; i < arr.size(); i++) {
      |                    ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 53 ms 348 KB Output is correct
6 Correct 109 ms 348 KB Output is correct
7 Correct 63 ms 460 KB Output is correct
8 Correct 117 ms 508 KB Output is correct
9 Correct 35 ms 464 KB Output is correct