为什么加了ios会炸(这是加强版吗?)
查看原帖
为什么加了ios会炸(这是加强版吗?)
996296
wang_changyue楼主2025/8/31 15:06
#include<bits/stdc++.h>
using namespace std;
#define int long long
/*====================*/
const int N=5e5+10;
/*====================*/
const int INF=0x3f3f3f3f;
const int MOD=998244353;
/*====================*/
int n,a[N],u[N];
void Solve(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>u[i]>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)ans+=max(u[i],u[j])*abs(a[i]-a[j]);
    cout<<ans;
}
/*====================*/
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int T=1;//cin>>T;
	while(T--){
		Solve();
	}
	return 0;
}

加了ios::sync_with_stdio(false);

#include<bits/stdc++.h>
using namespace std;
#define int long long
/*====================*/
const int N=5e5+10;
/*====================*/
const int INF=0x3f3f3f3f;
const int MOD=998244353;
/*====================*/
int n,a[N],u[N];
void Solve(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>u[i]>>a[i];
    int ans=0;
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)ans+=max(u[i],u[j])*abs(a[i]-a[j]);
    cout<<ans;
}
/*====================*/
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	//ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int T=1;//cin>>T;
	while(T--){
		Solve();
	}
	return 0;
}

不加ios::sync_with_stdio(false);

2025/8/31 15:06
加载中...