RE的智慧

P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

@[WuKaipeng](/user/889093) 首先,开long long,其次,开long long,最后,开long long!!!!!!!!
by _Clown__ @ 2023-08-18 10:44:28


@[WuKaipeng](/user/889093) 把 ```cpp int a[5001]; ``` 改为 ```cpp long long a[10001]; ```
by _Clown__ @ 2023-08-18 10:45:54


@[ng_bf](/user/593499) 继续RE(
by WindowsWKP @ 2023-08-18 10:47:01


emmm……
by _Clown__ @ 2023-08-18 10:48:17


tle能理解,还re肿么肥似
by _Clown__ @ 2023-08-18 10:49:58


@[WuKaipeng](/user/889093) ``` #include<bits/stdc++.h> using namespace std; #define int long long const int N=9999999; int a[N]; signed main(){ int minn,minnn,n,b=0,t,l; cin>>n; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++){ if (a[j]!=-1&&a[j]<minn){ minn=a[j]; l=j; } } for (int j=1;j<=n;j++){ if (l!=j&&a[j]!=-1&&a[j]<minnn){ minnn=a[j]; t=j; } } b+=minnn+minn; a[t]=b; a[l]=-1; } cout<<b; return 0; } ``` ![](https://cdn.luogu.com.cn/upload/image_hosting/vb8lylmj.png) 。。。。
by Huge_Brain @ 2023-08-18 10:51:52


果然awa
by _Clown__ @ 2023-08-18 10:52:47


递推快排解决awa
by _Clown__ @ 2023-08-18 10:53:19


@[WuKaipeng](/user/889093) 给您参考一下: ```cpp sort(a+1,a+n+1); for(int i=1;i<n;i++) { a[i+1]+=a[i]; ans+=a[i+1]; sort(a+1,a+n+1); } cout<<ans; ```
by _Clown__ @ 2023-08-18 10:54:37


```cpp #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod=998244353,N=1e3+10; inline ll read(){ ll x=0;bool f=0;char ch=getchar(); while(ch<'0'||ch>'9'){f|=ch=='-';ch= getchar();} while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch= getchar();} return f?-x:x; } inline void read(ll &x){x=read();} template<typename T,typename ...Args>inline void read(T &x,Args &...args) { read(x); read(args...); } ll n,ans; priority_queue<ll>q; int main(){ read(n); for(ll i=1;i<=n;i++)q.push(-read()); while(q.size()>1){ ll temp=q.top();q.pop(); ll res=q.top()+temp;q.pop(); ans-=res;q.push(res); } printf("%lld ",ans); return 0; } ```
by _Regenbogen_ @ 2023-08-18 10:57:05


| 下一页