QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#412966 | #5252. Deforestation | Liberty12619# | WA | 10ms | 3800kb | C++20 | 1.1kb | 2024-05-16 22:39:47 | 2024-05-16 22:39:47 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N = 1e6+10,mod = 998244353,INF=1e12,cap = 20210926;
int W,ans;
int dfs()
{
int x,y;
cin>>x>>y;
vector<int>nums(y+1,0);
for(int i=1;i<=y;i++) nums[i]=dfs();
int res=x,tmp=0;
for(int i=1;i<=y;i++)
{
res+=nums[i];
tmp+=res/W;
res%=W;
}
tmp+=res/W,res%=W;
reverse(nums.begin()+1,nums.end());
int res1=x,tmp1=0;
for(int i=1;i<=y;i++)
{
res1+=nums[i];
tmp1+=res1/W;
res1%=W;
}
tmp1+=res1/W,res1%=W;
if(tmp>tmp1) swap(tmp,tmp1),swap(res,res1);
else if(tmp==tmp1&&res>res1) swap(res,res1);
ans+=tmp;
return res;
}
void solve()
{
cin>>W;
int res = dfs();
if(res) ans++;
cout<<ans<<"\n";
}
signed main()
{
int T=1;
cin.tie(0)->sync_with_stdio(false);
//cin>>T;
//init();
while(T--)
{
solve();
}
return 0;
}
/*
5
2 3
2 2
1 0
1 0
6 0
4 2
3 0
2 0
*/
详细
Test #1:
score: 100
Accepted
time: 10ms
memory: 3548kb
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: 8ms
memory: 3800kb
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'