Submission #89118

# Submission time Handle Problem Language Result Execution time Memory
89118 2018-12-10T10:45:18 Z tamazineb Schools (IZhO13_school) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
int n,t=0,j=0,p=0,m,k,mx=-1,nx=-1,o,q;
cin>>n>>m>>k;
int a[n+1],b[n+1];
for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i];
    t=t+a[i];
    j=j+b[i];
}
if(t>=j){
while(k!=0){
for(int v=1;v<=n;v++){
   if(b[v]>=mx){
        mx=b[v];
    q=v;
   }
}
k--;
p=p+mx;
 b[q]=-2;
 a[q]=-2;


}


while(m!=0){
   for(int v=1;v<=n;v++){
    if(a[v]>=nx){
        nx=a[v];
    o=v;
    }
   }
   m--;
  p=p+nx;
  a[o]=-2;
  b[o]=-2;
}

}


else
{


while(m!=0){
for(int v=1;v<=n;v++){
   if(a[v]>=nx){
        xn=a[v];
    q=v;
   }
}
m--;
p=p+nx;
 a[q]=-2;
 b[q]=-2;


}


while(k!=0){
   for(int v=1;v<=n;v++){
    if(b[v]>=mx){
        mx=b[v];
    o=v;
    }
   }
   k--;
  p=p+mx;
  b[o]=-2;
  a[o]=-2;
}



}
 cout<<p;



    return 0;
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:55:9: error: 'xn' was not declared in this scope
         xn=a[v];
         ^~
school.cpp:55:9: note: suggested alternative: 'n'
         xn=a[v];
         ^~
         n