# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
495877 | asandikci | ACM (COCI19_acm) | C++17 | 11 ms | 508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |