답안 #711604

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711604 2023-03-17T09:40:42 Z pcc ACM (COCI19_acm) C++14
50 / 50
8 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

string tar = "NijeZivotJedanACM";
struct node{
    string name;
    ll cnt,pen;
    node(){
        cnt = pen = 0;
    }
    bool operator<(node &b){
        if(cnt != b.cnt)return cnt>b.cnt;
        else if(pen != b.pen)return pen<b.pen;
        else return name<b.name;
    }
};
vector<node> v;
int main(){
    int n,m;
    cin>>n>>m;
    string sssss;
    getline(cin,sssss);
    for(int j = 0;j<n;j++){
        string in;
        getline(cin,in);
        // cout<<in<<endl<<endl;
        stringstream ss(in);
        ss>>in;
        if(in == tar)continue;
        node tmp;
        tmp.name = in;
        while(ss>>in){
            if(in[0] != '-'){
                tmp.cnt++;
            }
            string num;
            for(int i = 1;i<in.size();i++){
                if(in[i] == '/')break;
                num += in[i];
            }
            if(num.empty())num = "1";
            if(in[0] != '-')tmp.pen +=20*(stoi(num)-1)*60;
            if(in[0] != '-'){
                in = in.substr(in.size()-8,8);
                tmp.pen += 3600*stoi(in.substr(0,2));
                tmp.pen += 60*stoi(in.substr(3,2));
                tmp.pen += stoi(in.substr(6,2));
            }
        }
        v.push_back(tmp);
    }
    string in;
    getline(cin,in);
    stringstream ss(in);
    ss>>in;
    node tmp;
    tmp.name = in;
    while(ss>>in){
        if(in[0] != '-'){
            tmp.cnt++;
        }
        string num;
        for(int i = 1;i<in.size();i++){
            if(in[i] == '/')break;
            num += in[i];
        }
        if(num.empty())num = "1";
        if(in[0] != '-')tmp.pen +=20*(stoi(num)-1)*60;
        if(in[0] != '-'){
            in = in.substr(in.size()-8,8);
            tmp.pen += 3600*stoi(in.substr(0,2));
            tmp.pen += 60*stoi(in.substr(3,2));
            tmp.pen += stoi(in.substr(6,2));
        }
    }
    v.push_back(tmp);
    sort(v.begin(),v.end());
    // cout<<endl;
    // for(auto &i:v)cout<<i.name<<' '<<i.cnt<<' '<<i.pen<<endl;
    // cout<<endl;
    for(int i =0;i<v.size();i++){
        if(v[i].name == tar){
            cout<<i+1<<'\n';
            return 0;
        }
    }
    cout<<"ERROR\n";
    return 0;
}

Compilation message

acm.cpp: In function 'int main()':
acm.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |             for(int i = 1;i<in.size();i++){
      |                           ~^~~~~~~~~~
acm.cpp:65:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i = 1;i<in.size();i++){
      |                       ~^~~~~~~~~~
acm.cpp:83:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<node>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |     for(int i =0;i<v.size();i++){
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 8 ms 344 KB Output is correct
5 Correct 8 ms 340 KB Output is correct