You are viewing a single comment's thread. Return to all comments →
#include<stdio.h> long int sort(int a[] ,int size,int k){ int i,min,j,sum=0,t; for(i=0;i<k;i++){ min=i; for(j=i+1;j<size;j++){ if(a[min]>a[j]) min=j; } if(i!=min){ t=a[i]; a[i]=a[min]; a[min]=t; } sum+=a[i]; } return sum; } int main(){ int n,k,i,t; long int l,sum1=0,sum2; int ar[100],arc=0; scanf("%d %d",&n,&k); for(i=0;i<n;i++){ scanf("%ld %d",&l,&t); if(t==1) ar[arc++]=l; sum1+=l; } sum2=sort(ar,arc,arc-k); printf("%ld",(sum1- 2*(sum2))); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →