Submission #1013029

# Submission time Handle Problem Language Result Execution time Memory
1013029 2024-07-03T05:56:07 Z vjudge1 ACM (COCI19_acm) C++17
40 / 50
6 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	int ns[n]={},pen[n]={},id;
	string nm[n];
	for (int t=0;t<n;t++)
	{
		cin>>nm[t];
		if (nm[t]=="NijeZivotJedanACM")
			id=t;
		for (int i=0;i<m;i++)
		{
			string s;
			cin>>s;
			if (s[0]!='-')
			{
				ns[t]++;
				int sub=0,ind=0;
				int fac[4]={1200,3600,60,1};
				for (int j=1;j<s.size();j++)
				{
					if (s[j]=='/' or s[j]==':')
					{
						pen[t]+=sub*fac[ind];
						ind++;
						sub=0;
						continue;
					}
					sub=sub*10+s[j]-'0';
				}
				pen[t]-=1200;
			}
		}
	}
	cin>>nm[id];
	ns[id]=pen[id]=0;
	for (int i=0;i<m;i++)
	{
		string s;
		cin>>s;
		if (s[0]=='+')
		{
			ns[id]++;
			int sub=0,ind=0;
			int fac[4]={1200,3600,60,1};
			for (int j=1;j<s.size();j++)
			{
				if (s[j]=='/' or s[j]==':')
				{
					pen[id]+=sub*fac[ind];
					ind++;
					sub=0;
					continue;
				}
				sub=sub*10+s[j]-'0';
			}
			pen[id]-=1200;
		}
	}
	int pos=1;
	for (int i=0;i<n;i++)
	{
		if (i==id)
			continue;
		if (ns[i]>ns[id])
			pos++;
		else if(ns[i]==ns[id])
		{
			if (pen[id]>pen[i])
				pos++;
			else if(pen[id]==pen[i] && nm[i]<nm[id])
				pos++;
		}
	}
	cout<<pos<<endl;
	
	return 0;
}

Compilation message

acm.cpp: In function 'int main()':
acm.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int j=1;j<s.size();j++)
      |                  ~^~~~~~~~~
acm.cpp:51:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |    for (int j=1;j<s.size();j++)
      |                 ~^~~~~~~~~
acm.cpp:74:14: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   74 |    if (pen[id]>pen[i])
      |        ~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 3 ms 348 KB Output is correct
5 Incorrect 6 ms 344 KB Output isn't correct