QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#249922#7528. Effective ManagementNestik_55#WA 0ms3768kbC++201.4kb2023-11-12 18:03:122023-11-12 18:03:13

Judging History

你现在查看的是最新测评结果

  • [2023-11-12 18:03:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3768kb
  • [2023-11-12 18:03:12]
  • 提交

answer

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int n;
vector<ll> profit;
vector<ll> ptime;
vector<vector<int>> g;

vector<ll> actTime;
vector<int> ans;

pair<ll, ll> mxRat = { 0, 1 };

bool lt(pair<ll, ll> a, pair<ll, ll> b) {
	return a.first * b.second < b.first * a.second;
}

bool eq(pair<ll, ll> a, pair<ll, ll> b) {
	return a.first * b.second == b.first * a.second;
}

void dfs(int v) {
	ll mxTime = ptime[v];
	for (int u : g[v]) {
		if (actTime[u] == -1) {
			dfs(u);
			mxTime = max(mxTime, ptime[u]);
		}
	}

	actTime[v] = mxTime;
	if (lt(mxRat, { profit[v], actTime[v] }))
		mxRat = { profit[v], actTime[v] };

	//cout << "v, act: " << v << ' ' << actTime[v] << endl;
}

int main() {
	cin >> n;
	profit.resize(n + 1);
	ptime.resize(n + 1);
	g.resize(n + 1);
	actTime.resize(n + 1, -1);

	vector<int> inCnt(n + 1);

	for (int i = 1; i <= n; ++i)
		cin >> profit[i];
	for (int i = 1; i <= n; ++i)
		cin >> ptime[i];

	for (int i = 1; i <= n; ++i) {
		int m;
		cin >> m;
		for (int j = 0; j < m; ++j) {
			int x;
			cin >> x;
			++inCnt[x];
			g[i].push_back(x);
		}
	}

	for (int v = 1; v <= n; ++v) {
		if (actTime[v] == -1 && inCnt[v] == 0)
			dfs(v);
	}

	for (int v = 1; v <= n; ++v) {
		if (eq({profit[v], actTime[v]}, mxRat))
			cout << v << '\n';
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

6
1 2 4 5 4 6
1 3 2 2 3 2
0
0
1 1
2 2 3
1 1
2 5 4

output:

3
6

result:

ok 2 number(s): "3 6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

5
10 9 5 4 1
4 6 2 3 1
1 2
1 3
1 4
1 5
0

output:

1
3

result:

ok 2 number(s): "1 3"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

6
2 4 6 8 10 12
1 2 3 4 5 6
0
0
0
0
0
0

output:

1
2
3
4
5
6

result:

ok 6 numbers

Test #4:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

3
999999999 1000000000 999999998
999999998 999999999 999999997
0
0
0

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5
7 10 1 9 6
7 5 6 1 3
1 3
0
0
1 5
0

output:

4

result:

ok 1 number(s): "4"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

5
1 2 8 5 2
1 7 9 9 4
1 3
2 3 5
2 4 5
0
0

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 3588kb

input:

5
7 6 3 5 1
6 9 3 10 10
1 4
0
2 4 1
0
3 1 4 3

output:

3

result:

wrong answer 1st numbers differ - expected: '1', found: '3'