QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#399727 | #2823. 改善生活 | ucup-team1251 | WA | 3ms | 16620kb | C++17 | 1.5kb | 2024-04-26 17:25:11 | 2024-04-26 17:25:11 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <bitset>
#include <cstdio>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define lowbit(x) x&(-x)
#define pi 3.14159265358
#define lc k<<1;
#define rc k<<1|1
#define ppb push_back
#define mod 1000000007
#define fori(i,l,r) for(int i=l;i<=r;i++)
#define forj(j,l,r) for(int j=l;j<=r;j++)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair <int, int> pll;
const int N = 2e5 + 10;
const int P = 131;
ll t, n, m,a,b;
double aa = 0, bb = 0;
ll ans = 0;
ll arr[N];
ll w[N];
ll as[N];
vector<ll>e[N];
vector<ll>v[N];
map<int, int>mp;
bool p[N];
void dfs1(int x){
for (auto c : v[x]){
if (!mp[c]){
mp[c] = 1;
as[arr[c]] += w[c];
dfs1(c);
mp[c] = 0;
}
}
}
void ac(){
cin >> n >> m;
for (int i = 1; i <= n; i++){
cin >> arr[i];
if (arr[i] == 1)mp[i] = 1;
e[arr[i]].push_back(i);
}for (int i = 1; i <= n; i++)cin >> w[i];
for (int i = 1; i <= m; i++){
cin >> a >> b;
v[a].push_back(b);
}for (auto c : e[1]){
bb = w[c];
mp[c] = 1;
dfs1(c);
mp[c] = 0;
for (int i = 2; i <= n; i++){
double vv = as[i] / bb;
ll ad = floor(vv);
ans = max(ans, ad);
as[i] = 0;
}
}cout << ans;
}
int main() {
ios::sync_with_stdio(0);
cin.tie();
cout.tie();
t = 1;
while (t--){
ac();
}
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 16476kb
input:
7 8 2 2 1 1 3 3 4 100 100 40 20 100 50 40 1 3 2 3 1 4 2 4 3 5 4 6 3 7 4 7
output:
2
result:
ok single line: '2'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 16620kb
input:
15 36 1 1 1 1 1 1 1 3 3 4 5 5 6 4 2 1 5 4 16 1 16 9 98 84 69 4 95 53 99 64 1 8 2 8 3 8 4 8 5 8 6 8 7 8 8 9 8 11 9 8 9 10 9 11 9 12 9 14 10 8 10 11 10 12 11 8 11 9 11 10 11 12 11 14 12 13 12 14 13 8 13 9 13 10 13 12 13 14 13 15 14 10 14 13 14 15 15 9 15 11 15 13
output:
6972
result:
wrong answer 1st lines differ - expected: '182', found: '6972'