Submission #340262

# Submission time Handle Problem Language Result Execution time Memory
340262 2020-12-27T11:04:37 Z A_D ACM (COCI19_acm) C++14
50 / 50
7 ms 384 KB
/*
ID: antwand1
TASK: barn1
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define du long double
#define F first
#define S second
using namespace std;
const int N=1e3+100;
string f="NijeZivotJedanACM";
pair<pair<ll,ll>,string> a[N];
main()
{
    //freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout);
    int n,m;
    cin>>n>>m;
    int cu=0;
    for(int i=1;i<=n;i++){
        string res;
        cin>>res;
        if(res==f){
            cu=i;
        }
        ll ad=0,pen=0;
        for(int j=1;j<=m;j++){
            ll ben=0;
            string t;
            cin>>t;
            if(t[0]=='-')continue;
            ad++;
            ll q=0;
            reverse(t.begin(),t.end());
            t.pop_back();
            while(t.back()!='/'){
                ben*=10;
                ben+=t.back()-'0';
                t.pop_back();
            }
            t.pop_back();
            ben*=20*60;
            reverse(t.begin(),t.end());
            ll h=(t[0]-'0')*10+(t[1]-'0');
            reverse(t.begin(),t.end());
            ben+=h*3600;
            t.pop_back();t.pop_back();t.pop_back();
            reverse(t.begin(),t.end());
            h=(t[0]-'0')*10+(t[1]-'0');
            reverse(t.begin(),t.end());
            ben+=h*60;
            t.pop_back();t.pop_back();t.pop_back();
            reverse(t.begin(),t.end());
            h=(t[0]-'0')*10+(t[1]-'0');
            ben+=h;
            pen+=ben;
        }
        //break;
        a[i]={{-ad,pen},res};
    }
    string res;
    cin>>res;
    int i=cu;
    ll ad=0,pen=0;
    for(int j=1;j<=m;j++){
        ll ben=0;
        string t;
        cin>>t;
        if(t[0]=='-')continue;
        ad++;
        ll q=0;
        reverse(t.begin(),t.end());
        t.pop_back();
        while(t.back()!='/'){
            ben*=10;
            ben+=t.back()-'0';
            t.pop_back();
        }
        t.pop_back();
        ben*=20*60;
        reverse(t.begin(),t.end());
        ll h=(t[0]-'0')*10+(t[1]-'0');
        reverse(t.begin(),t.end());
        ben+=h*3600;
        t.pop_back();t.pop_back();t.pop_back();
        reverse(t.begin(),t.end());
        h=(t[0]-'0')*10+(t[1]-'0');
        reverse(t.begin(),t.end());
        ben+=h*60;
        t.pop_back();t.pop_back();t.pop_back();
        reverse(t.begin(),t.end());
        h=(t[0]-'0')*10+(t[1]-'0');
        ben+=h;
        pen+=ben;
    }
    a[i]={{-ad,+pen},res};
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
      //  cout<<a[i].F.F<<" "<<a[i].F.S<<" "<<a[i].S<<endl;
        if(a[i].S==f){
            cout<<i<<endl;
            //break;
        }
    }
}



Compilation message

acm.cpp:15:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      |      ^
acm.cpp: In function 'int main()':
acm.cpp:34:16: warning: unused variable 'q' [-Wunused-variable]
   34 |             ll q=0;
      |                ^
acm.cpp:72:12: warning: unused variable 'q' [-Wunused-variable]
   72 |         ll q=0;
      |            ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 7 ms 364 KB Output is correct
5 Correct 7 ms 384 KB Output is correct