QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#717846 | #9437. Solve with Friends | jimmyywang | WA | 1ms | 9776kb | C++14 | 687b | 2024-11-06 19:05:50 | 2024-11-06 19:05:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<=b;i++)
ll read(){
ll x=0,f=1;char c=getchar();
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}
return x*f;
}
#define d read()
ll a[200010],b[200010];
ll x[200010],y[200010];
ll n,s,c[200010];
ll res=0x3f3f3f3f3f3f3f3f;
int main(){
n=d;
f(i,1,n)a[i]=d,s+=a[i];
f(i,1,n)b[i]=d,c[i]=b[i]-a[i];
sort(c+1,c+n+1);f(i,1,n)c[i]+=c[i-1];
x[0]=d;f(i,1,n-1)x[i]=x[i-1]+d;
y[0]=d;f(i,1,n-1)y[i]=y[i-1]+d;
f(i,0,n)res=min(res,x[i-1]+y[n-i-1]+s+c[n-i]);
cout<<res<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 9776kb
input:
3 1 3 5 6 4 2 1 2 3 1 2 3
output:
10
result:
ok "10"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 9768kb
input:
5 2 4 3 1 2 9 2 5 3 8 1 2 8 3 2 5 4 3 2 1
output:
29
result:
wrong answer 1st words differ - expected: '28', found: '29'