QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#249914 | #7528. Effective Management | Nestik_55# | WA | 1ms | 3476kb | C++20 | 1.2kb | 2023-11-12 17:57:11 | 2023-11-12 17:57:12 |
Judging History
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;
long double mxRat = 0;
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;
mxRat = max(mxRat, ((long double)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 (((long double)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: 1ms
memory: 3440kb
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: 3376kb
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: 3380kb
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: 3404kb
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: 3444kb
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: 3424kb
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: 3476kb
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'