Submission #1257558

#TimeUsernameProblemLanguageResultExecution timeMemory
1257558E_rKACM (COCI19_acm)C++20
50 / 50
10 ms15688 KiB
#include <bits/stdc++.h>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define sp " "
// #define endl "\n"
#define mod 1000000007
#define MAXN 200005
#define MAXM 1000006
#define inf 1e18
#define INF 0x3f
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) for(auto& a: x) cout << a << " "
 
using namespace std;
typedef long long int lo;
 
lo n,m,p,q,k,l,a,b;

lo arr[MAXN];
lo len[MAXN];

vector<lo> v[MAXN];

string s;
vector<lo> dp;
string names[1005];
string sorular[1006][40];
pair<lo,pair<lo,string>> score[MAXN];
lo cnt[MAXN];
lo timetoscore(string s){
    // cout << s[1] << sp;
    lo pen = (s[1] - '1') * 1200;

    
    lo pentime = (s[4] - '0') * 3600 + ((s[6] - '0') * 600) + ((s[7]-'0')*60) + (s[9]-'0')*10 + s[10]-'0';
    // cout << s << sp << pentime << endl;
    return pen + pentime;
}
bool cmp(pair<lo,pair<lo,string>> a, pair<lo,pair<lo,string>> b){
    if(a.fi == b.fi){
        if(a.se.fi == b.se.fi)
            return a.se.se < b.se.se;
        return a.se.fi < b.se.fi;
    }
    return a.fi > b.fi;
}
void solve(){    
    cin >> n >> m;
    lo emir = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> names[i];
        // cerr << ++emir << endl;
        // cout << names[i] << endl;
        for (int j = 0; j < m; ++j)
        {
            cin >> sorular[i][j];
            score[i].se.se = names[i];
            if(names[i] == "NijeZivotJedanACM"){
                continue;
            }
            // if(names[i] == "zrdwczynjuiwzabpgwoh"){
            //     cout << "a" << endl;
            // }
            if(sorular[i][j][0] == '-'){
                // if(sorular[i][j].size() > 1){
                //     score[i].se.fi += (sorular[i][j][1] - '0') * 1200;
                // }
                continue;
            }
            cnt[i]++;
            // cout << i << sp;
            // cout<< sorular[i][j] << sp << timetoscore(sorular[i][j]) << endl;
            score[i].fi++;;
            score[i].se.fi += timetoscore(sorular[i][j]);
        }
        // cerr << emir << endl;
    }
    string name,benim[m+1];
    lo benimscore=0;
    cin >> name;
    lo cnt = 0;
    for (int j = 0; j < m; ++j)
    {
        cin >> benim[j];
        if(benim[j][0] == '-'){
            // if(benim[j].size() > 1)
            //     benimscore += (benim[j][1] - '0') * 1200;
            continue;
        }
        if(benim[j][0] == '+')
            cnt++;
        benimscore += timetoscore(benim[j]);
    }
    sort(score,score+n,cmp);
    // for (int i = 0; i < n-1; ++i)
    // {
    //     cout << score[i].fi << sp << score[i].se.fi << sp << score[i].se.se << endl;;
    // }
    // cout<< cnt << sp<< benimscore << endl; 
    // cout << endl;
    for (int i = 0; i < n-1; ++i)
    {
        if(cnt < score[i].fi)
            continue;
        if(cnt > score[i].fi){
            cout << i+1 << endl;
            return;
        }
        if(cnt == score[i].fi and benimscore < score[i].se.fi){
            // cout << i << sp << benimscore << sp << score[i].se.fi << endl;
            
            cout << i+1 << endl;
            return;
        }
    }
    cout << n << endl;
    // cout <<endl<< benimscore << endl;

}
int main()
{
    // cout << fixed << setprecision(12);
    // freopen("feast.in","r",stdin);
    // freopen("feast.out","w",stdout);
    // fast;[Finished in 546ms]
    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...