Submission #495877

#TimeUsernameProblemLanguageResultExecution timeMemory
495877asandikciACM (COCI19_acm)C++17
50 / 50
11 ms508 KiB
#include"iostream" #include"vector" // #include"queue" // #include"deque" // #include"set" #include"map" #include"algorithm" // #include"iomanip" #include"cstring" #define int long long using namespace std; map<string,pair<int,pair<int,int>>> mp; // str - hash -> {maxP , Penalty} bool cmp(pair<string,pair<int,int>> a, pair<string,pair<int,int>> b){ if(a.second.first!=b.second.first){return a.second.first>b.second.first;} if(a.second.second!=b.second.second){return a.second.second<b.second.second;} return a.first < b.first; } void solve(){ int n,t; cin >> n >> t; int num=1; for(int i=0;i<n;i++){ string str; cin >> str; if(str=="NijeZivotJedanACM"){ for(int j=0;j<t;j++){ char ch; cin >> ch; string tmp; if(ch=='-'){ // mp[str].second.second+=20*60; char ch2; ch2 = getchar(); // cout << ch2 << "\n"; continue; } if(ch=='+' || ch=='?'){cin >> tmp;} } continue; } if(mp[str].first==0){mp[str].first=num++;} for(int j=0;j<t;j++){ char ch; cin >> ch; string tmp; if(ch=='-'){ mp[str].second.second+=20*60; char ch2; ch2 = getchar(); // cout << ch2 << "\n"; continue; } if(ch=='+'){ cin >> tmp; if(tmp[1]=='/'){ mp[str].second.first+=1; mp[str].second.second+= 20*60*(tmp[0]-'0'); int rem=0; string tmp2 =""; tmp2 += tmp[2]; tmp2 += tmp[3]; rem+=(stoi(tmp2)*3600); string tmp3 =""; tmp3 += tmp[5]; tmp3 += tmp[6]; rem+=(stoi(tmp3)*60); string tmp4 =""; tmp4 += tmp[8]; tmp4 += tmp[9]; rem+=(stoi(tmp4)); mp[str].second.second+=rem; } } if(ch=='?'){ cin >> tmp; if(tmp[1]=='/'){ mp[str].second.first+=1; mp[str].second.second+= 20*60*(tmp[0]-'0'); int rem=0; string tmp2 =""; tmp2 += tmp[2]; tmp2 += tmp[3]; rem+=(stoi(tmp2)*3600); string tmp3 =""; tmp3 += tmp[5]; tmp3 += tmp[6]; rem+=(stoi(tmp3)*60); string tmp4 =""; tmp4 += tmp[8]; tmp4 += tmp[9]; rem+=(stoi(tmp4)); mp[str].second.second+=rem; } } } } string str; cin >> str; mp[str].first=1001; for(int j=0;j<t;j++){ char ch; cin >> ch; string tmp; if(ch=='-'){ mp[str].second.second+=20*60; char ch2; ch2 = getchar(); // cout << ch2 << "\n"; continue; } if(ch=='+'){ cin >> tmp; if(tmp[1]=='/'){ mp[str].second.first+=1; mp[str].second.second+= 20*60*(tmp[0]-'0'); int rem=0; string tmp2 =""; tmp2 += tmp[2]; tmp2 += tmp[3]; rem+=(stoi(tmp2)*3600); string tmp3 =""; tmp3 += tmp[5]; tmp3 += tmp[6]; rem+=(stoi(tmp3)*60); string tmp4 =""; tmp4 += tmp[8]; tmp4 += tmp[9]; rem+=(stoi(tmp4)); mp[str].second.second+=rem; } } if(ch=='?'){ cin >> tmp; if(tmp[1]=='/'){ mp[str].second.first+=1; mp[str].second.second+= 20*60*(tmp[0]-'0'); int rem=0; string tmp2 =""; tmp2 += tmp[2]; tmp2 += tmp[3]; rem+=(stoi(tmp2)*3600); string tmp3 =""; tmp3 += tmp[5]; tmp3 += tmp[6]; rem+=(stoi(tmp3)*60); string tmp4 =""; tmp4 += tmp[8]; tmp4 += tmp[9]; rem+=(stoi(tmp4)); mp[str].second.second+=rem; } } } int maxi=0; for(auto it : mp){ maxi=max(maxi,it.second.second.first); } vector<pair<string,pair<int,int>>> vec; for(auto it : mp){ vec.push_back({it.first,{it.second.second.first,it.second.second.second}}); } sort(vec.begin(),vec.end(),cmp); // for(auto it : mp){ // if(it.second.second.first==maxi){ // vec.push_back({it.first,it.second.second.second}); // } // } // for(auto it : vec){ // cout << it.first << "-> " << it.second.first << " - " << it.second.second << "\n"; // }cout << "\n\n"; // for(auto it : mp){ // cout << it.second.first << " " << it.second.second.first << " " << it.second.second.second << "\n"; // }cout << "\nans: "; for(int i=0;i<n;i++){ if(vec[i].first=="NijeZivotJedanACM"){ cout << i+1 << "\n"; } } } signed main(){ // ios::sync_with_stdio(false); cin.tie(0); // freopen("","r",stdin);freopen("","w",stdout); int t=1; // cin >> t; for(int i=1;i<=t;i++){ // cout << "Case " << i << ":\n"; solve(); } }

Compilation message (stderr)

acm.cpp: In function 'void solve()':
acm.cpp:36:16: warning: variable 'ch2' set but not used [-Wunused-but-set-variable]
   36 |           char ch2;
      |                ^~~
acm.cpp:52:14: warning: variable 'ch2' set but not used [-Wunused-but-set-variable]
   52 |         char ch2;
      |              ^~~
acm.cpp:110:12: warning: variable 'ch2' set but not used [-Wunused-but-set-variable]
  110 |       char ch2;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...