还是4个1a

记录代码

 

A

 1 //#define txtout
 2 //#define debug
 3 #include<bits/stdc++.h>
 4 #define mt(a,b) memset(a,b,sizeof(a))
 5 using namespace std;
 6 typedef long long LL;
 7 const double pi=acos(-1.0);
 8 const double eps=1e-8;
 9 const int inf=0x3f3f3f3f;
10 const int M=1e5+10;
11 int n,m;
12 int a[M];
13 bool v[M];
14 void solve(){
15 
16 }
17 int main(){
18     #ifdef txtout
19     freopen("in.txt","r",stdin);
20     freopen("out.txt","w",stdout);
21     #endif // txtout
22     while(~scanf("%d",&n)){
23         int sum=0;
24         for(int i=1;i<=n;i++){
25             scanf("%d",&a[i]);
26             sum+=a[i];
27             v[i]=false;
28         }
29         int avg=sum*2/n;
30         for(int i=1;i<=n;i++){
31             bool flag=false;
32             for(int j=1;j<=n;j++){
33                 if(v[j]) continue;
34                 for(int k=j+1;k<=n;k++){
35                     if(v[k]) continue;
36                     if(a[j]+a[k]==avg){
37                         flag=true;
38                         printf("%d %d\n",j,k);
39                         v[j]=true;
40                         v[k]=true;
41                         break;
42                     }
43                 }
44                 if(flag) break;
45             }
46         }
47     }
48     return 0;
49 }
View Code

相关文章: