답안 #685255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685255 2023-01-23T18:54:43 Z 3as8 ACM (COCI19_acm) C++14
50 / 50
7 ms 520 KB
#include <bits/stdc++.h>

#define ll long long
#define endl "\n"

using namespace std;

bool comp(const pair<pair<ll,ll>, string> &a, const pair<pair<ll,ll>, string> &b){
    if(a.first.first > b.first.first) return true;
    else if(a.first.first < b.first.first) return false;
    else {
        if( a.first.second < b.first.second) return true;
        else if(a.first.second > b.first.second) return false;
        else return  a.second < b.second;
    }

    //return (a.first.first > b.first.first && a.first.second < b.first.second && a.second < b.second);
}

void getTeam(ll& penaltyTime, ll& solved, ll k ) {

    solved = 0;
    penaltyTime = 0;

    for(int j = 0; j < k; j++) {
        string s; cin>>s;
        char type = s[0];

        back:
        if(type == '-') {}
        else {
            solved += 1;

            char atts = s[1];

            ll attempts = int(atts) - 48;

            ll time = 0;

            ll mult = 3600;

            ll offset = 2;
            for(int l = 0; l < 3; l++) {
                char tensC = s[offset + 1], onesC = s[offset + 2];
                ll tens = int(tensC) - 48, ones = int(onesC) - 48;

                time += ((tens * 10) + ones) * mult;

                mult /= 60;
                if(l != 2) offset += 1;
                offset += 2;
            }

            time += ((20 * 60) * (attempts - 1) );

            penaltyTime += time;
        }

    }



}

void solve() {

    ll n, k; cin>>n>>k;

    map<string, pair<ll, ll> > teams;
    vector<pair<pair<ll, ll>, string> > teams1;

    for(int i = 0; i < n; i++) {
        string name; cin>>name;
        ll solved = 0;
        ll penaltyTime = 0;

        getTeam(penaltyTime, solved, k);

        if(name == "NijeZivotJedanACM") {}
        else {
            teams1.push_back({{solved, penaltyTime}, name});
        }

    }

    string s; cin>>s;
    ll penalty, solved; getTeam(penalty, solved, k);

    pair<pair<ll, ll>, string> myTeam = {{solved, penalty}, s};
    teams1.push_back(myTeam);

    sort(teams1.begin(), teams1.end(), comp);

    auto it = find(teams1.begin(), teams1.end(), myTeam);
    cout<<distance(teams1.begin(), it) + 1<<endl;

    //cout<<(n & (1 << k))<<endl;

    return;
}

int main(){

    solve();

    return 0;
}

Compilation message

acm.cpp: In function 'void getTeam(long long int&, long long int&, long long int)':
acm.cpp:29:9: warning: label 'back' defined but not used [-Wunused-label]
   29 |         back:
      |         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 520 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 7 ms 508 KB Output is correct
5 Correct 6 ms 444 KB Output is correct