답안 #495875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495875 2021-12-20T06:47:17 Z Nimbostratus ACM (COCI19_acm) C++17
50 / 50
20 ms 32020 KB
#include "bits/stdc++.h"
#define endl '\n'
#define fi first
#define se second
constexpr int maxn = 1005;
constexpr int inf = 2e9;
constexpr int mod = 1e9 + 7;
using namespace std;
using lint = long long;
using pii = pair<int, int>;

int n, m;
string sub[maxn][maxn];

struct score {
	int penalty = 0;
	bool ourteam = false;
	string name;
	void add(string& s, int idx) {
		if((ourteam && sub[n + 1][idx][0] == '-') || (!ourteam && s[0] == '-')) {
			penalty += 16 * 20000;
			return;
		}
		string hour = s.substr(3, 4);
		string min = s.substr(6, 7);
		string sec = s.substr(9, 10);
		penalty += stoi(hour) * 3600;
		penalty += stoi(min) * 60;
		penalty += stoi(sec);
		penalty += (s[1] - '0') * 1200;
	}
	friend bool operator<(score& x, score& y) {
		if(x.penalty < y.penalty)
			return true;
		if(x.penalty > y.penalty)
			return false;
		return x.name < y.name;
	}
};

score a[maxn];

signed main() {
	#ifdef Local
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].name;
		a[i].ourteam = a[i].name == "NijeZivotJedanACM";
		for(int j = 1; j <= m; j++)
			cin >> sub[i][j];
	}
	cin >> sub[n + 1][1];
	for(int i = 1; i <= m; i++)
		cin >> sub[n + 1][i];
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			a[i].add(sub[i][j], j);
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++)
		if(a[i].ourteam) {
			cout << i << endl;
			return 0;
		}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 31948 KB Output is correct
2 Correct 17 ms 31948 KB Output is correct
3 Correct 16 ms 31948 KB Output is correct
4 Correct 20 ms 31948 KB Output is correct
5 Correct 18 ms 32020 KB Output is correct