QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#139448#5252. Deforestationtselmegkh#WA 15ms11288kbC++201.2kb2023-08-13 16:12:322023-08-13 16:12:34

Judging History

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

  • [2023-08-13 16:12:34]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:11288kb
  • [2023-08-13 16:12:32]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
using namespace std;

const int N = 2e5 + 5, inf = 1e9;
#define pb push_back
#define mp make_pair
#define ll long long
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define sz(x) (int)x.size()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

vii g[N];
int cur = 2;
void scan(int n, int par){
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        cur++;
        g[par].pb({cur, a});
        scan(b, cur);
    }
}

ll dp[N];

void dfs(int u){
    for(auto [v, w] : g[u]){
        dfs(v);
        dp[u] += (dp[v] + w);
    }
}
void solve(){
    ll w, m;
    cin >> w >> m;
    int n;
    cin >> n;
    g[1].pb({2, m});
    
    scan(n, 2);
    dfs(1);

    cout << (dp[1] + w - 1) / w << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 15ms
memory: 11288kb

input:

999900000
7339 3
14947 2
12850 3
8986 10
11599 9
8889 10
10711 4
8015 1
11626 0
9492 1
7017 0
8863 0
8632 0
5321 5
9906 0
11687 0
9845 0
10469 0
11708 0
14950 5
11934 0
11922 0
13101 0
12000 0
9082 0
9273 5
12296 0
6119 0
9201 0
12652 0
12957 0
7454 5
12515 0
12976 0
10358 0
13997 0
8371 0
10181 5
8...

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 10ms
memory: 9556kb

input:

2
1 99999
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 ...

output:

50000

result:

wrong answer 1st lines differ - expected: '99999', found: '50000'