QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#74007 | #5252. Deforestation | ricky0129 | WA | 43ms | 11796kb | C++17 | 1.0kb | 2023-01-30 09:18:20 | 2023-01-30 09:18:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define FOR(i,n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
const int MOD = (int)1e9+7;
ll w;
ll ans = 0;
ll create(){
ll height,branches;
cin>>height>>branches;
ll remain = height;
vll br;
FOR(i,branches){
ll x = create();
if(x)
br.pb(x);
remain+=x;
}
sort(br.begin(),br.end());
while(sz(br)>1 && remain>w){
//cout<<"SEG"<<br.back()<<endl;
if(br.back())
ans++;
remain-=br.back();
br.pop_back();
}
ll k = remain/w;
ans+=k;
remain-=k*w;
return remain;
}
int main()
{
cin>>w;
ll x = create();
if(x)ans++;
cout<<ans<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 40ms
memory: 3368kb
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: 0
Accepted
time: 19ms
memory: 4072kb
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:
99999
result:
ok single line: '99999'
Test #3:
score: -100
Wrong Answer
time: 43ms
memory: 11796kb
input:
7 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10000 0 10000 2 10...
output:
142875000
result:
wrong answer 1st lines differ - expected: '142862500', found: '142875000'