本文共 1030 字,大约阅读时间需要 3 分钟。
题解:刚学了随机。。。立刻去搞之前一场比赛的题目
#include #include #include #include #include #include #include #include #include #include #include //CLOCKS_PER_SEC#define se second#define fi first#define ll long long#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define Pii pair #define Pli pair #define ull unsigned long long#define pb push_back#define fio ios::sync_with_stdio(false);cin.tie(0)const double Pi=3.14159265;const double e=2.71828182;const int N=2e3+5;const ull base=163;const int INF=0x3f3f3f3f;using namespace std;int a[N],b[N];int p[N];int main(){ fio; int n; cin>>n; srand(time(0)); for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ cin>>b[i]; } while(clock()<1.7*CLOCKS_PER_SEC){ ll l1=0,l2=0,r1=0,r2=0; int tot=0,cnt=0; for(int i=1;i<=n;i++){ int x=rand()%2; if(x==0)p[i]=0,l1+=a[i],l2+=b[i],tot++; else p[i]=1,r1+=a[i],r2+=b[i],cnt++; } if(l1>l2&&r1>r2){ cout< <<" "< <
转载于:https://www.cnblogs.com/Mrleon/p/8724734.html