Submission #222348

#TimeUsernameProblemLanguageResultExecution timeMemory
222348dantoh000ACM (COCI19_acm)C++14
50 / 50
19 ms768 KiB
#include <bits/stdc++.h> using namespace std; unordered_map<string,int> score; unordered_map<string,int> penalty; string names[1005]; int time(string s){ int h = 0, m = 0, S = 0; h = s[0]*10 + s[1]; m = s[3]*10 + s[4]; S = s[5]*10 + s[6]; return h*60*60 + m*60 + S; } int process(string name, string s){ //cout << name << " " << s << endl; if (s[0] == '-') return 0; if (s[0] == '+' || s[0] == '?'){ score[name]++; int num = s[1]; penalty[name] += num*20*60; string k = ""; for (int i = 3; i < s.size(); i++) k += s[i]; int t = time(k); penalty[name] += t; } } bool compare(string a, string b){ if (score[a] == score[b]) return penalty[a] < penalty[b]; else return score[a] > score[b]; } int main(){ int n,m; scanf("%d%d",&n,&m); for (int i = 0; i < n; i++){ string name; cin >> name; names[i] = name; for (int j = 0; j < m; j++){ string s; cin >> s; process(name,s); } } string name; cin >> name; score[name] = 0; penalty[name] = 0; for (int j = 0; j < m; j++){ string s; cin >> s; process(name,s); } int ans = 1; for (int i = 0; i < n; i++){ if (compare(names[i],name)) ans++; } printf("%d",ans); }

Compilation message (stderr)

acm.cpp: In function 'int process(std::__cxx11::string, std::__cxx11::string)':
acm.cpp:21:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 3; i < s.size(); i++) k += s[i];
                         ~~^~~~~~~~~~
acm.cpp:27:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
acm.cpp: In function 'int main()':
acm.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...