提交记录 20005
提交时间 |
评测时间 |
2023-08-22 16:59:32 |
2023-08-22 16:59:41 |
#include<bits/stdc++.h>
using namespace std;
const int SIZE=1e5+3;
int d[SIZE],n,sum,tot,ans,not0,le;
inline int ask(int x)
{
return d[x]-le;
}
int main()
{
cin>>n;
not0=n;
for(int i=1;i<=n;i++)
{
cin>>d[i];
if(d[i]==0) not0--;
sum+=d[i];
}
while(tot<sum)
{
int mi=0x3f3f3f3f;
bool yes=false;
int cnta=0;
not0=n;
for(int i=1;i<=n;i++)
{
// printf("Find Lastl=%d Lastr=%d || Nowl=%d Nowr=%d(YES?%d)\n",lastl,lastr,l,r,yes);
int idx=ask(i);
if(idx<=0)
{
not0--;
yes=false;
continue;
}
else
{
if(!yes) yes=true,cnta++;
mi=min(mi,idx);
}
}
le+=mi;
tot+=not0*mi;
ans+=mi*cnta;
}
cout<<ans;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 35.66 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 41.83 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 42.28 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 38.84 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 44.88 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 126.09 us | 40 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 931.62 us | 44 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 22.186 ms | 80 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 1 s | 232 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Testcase #10 | 1 s | 424 KB | Time Limit Exceeded | Score: 0 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2025-09-14 04:33:58 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠