#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 vll;
typedef unsigned __int128 uvll;
ll _i=0;
#define ffn(x) _i=x
#define llll pair<ll , ll>
#define stitr set<ll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define debu cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e13 + 7;
const ll ous=1e5 + 5;
const ll dx[4] = {0 , -1 , 1 , 0} , dy[4] = {1,0,0,-1};
void solve(){
ll n , m;cin >> n >> m;
map<string , ll> pen;
map<ll , vector<string>> lem;
for(ll i = 0;n>i;i++){
string h;
cin >> h;
if(h == "NijeZivotJedanACM"){
string y;
fora(i,m){
cin >> y;
}
continue;
}
ll ttp = 0 , ps = 0;
fora(i ,m){
string y;cin >> y;
//cout << y << "\n";
if(y[0]=='-'){
if(y.size() > 1){
/*ll tttt = 0;
for(ll i = 1;y.size()>i;i++){
tttt*=10;
tttt+=y[i]-48;
}
ttp+=tttt;*/
}
continue;
}
else{
ps++;
ll it = 1;
ll sp = 0 , tp = 0;
while(y[it] != '/'){
sp*=10;
sp+=y[it]-48;
it++;
}
it++;
tp = ((y[it+1]-48) * 3600) + (((y[it+3]-48)*10 + (y[it+4]-48))* 60) + ((y[it+6]-48)*10 + (y[it+7]-48));
ttp+=(sp-1)*1200 + tp;
}
}
pen[h] = ttp;
lem[ps].pb(h);
}
string h;
cin >> h;
ll pe = 0 , ps = 0;
fora(i , m){
string y;cin >> y;
if(y[0]=='-'){
/*ll tttt = 0;
for(ll i = 1;y.size()>i;i++){
tttt*=10;
tttt+=y[i]-48;
}
pe+=tttt;*/
continue;
}
else{
ps++;
ll it = 1;
ll sp = 0 , tp = 0;
while(y[it] != '/'){
sp*=10;
sp+=y[it]-48;
it++;
}
it++;
tp = ((y[it+1]-48) * 3600) + (((y[it+3]-48)*10 + (y[it+4]-48))* 60) + ((y[it+6]-48)*10 + (y[it+7]-48));
//cout << ps << "\n";
pe+=(sp-1)*1200 + tp;
}
}
pen[h] = pe;
//cout << pe << "\n";
ll drc = 0;
for(ll i =m;0<=i;i--){
//cout << lem[i].size() << "\n";
if(i != ps){
drc+=lem[i].size();
}
else{
for(auto j:lem[i]){
//cout << pen[j] << " " << j << "\n";
if(pen[j] < pen[h]){
drc++;
}
else if(pen[j] == pen[h] && j < h){
drc++;
}
}
break;
}
}
cout << drc+1 << "\n";
return;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
ll t=1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
460 KB |
Output is correct |
5 |
Correct |
2 ms |
460 KB |
Output is correct |