View Code of Problem 5

#include<iostream>
2.#include<algorithm>
3.using namespace std;
4.struct node{
5.	int a;
6.	int b;
7.	int id;
8.	int sum;
9.}f[100000]; 
10.bool cmp1(node x,node y){
11.	return x.sum>y.sum;
12.}
13. 
14.int main(){
15.	int t;
16.	cin>>t;
17.	while(t--){
18.		int n,m;
19.		cin>>n>>m;
20.		for(int i=0;i<n;i++){
21.			cin>>f[i].a>>f[i].b; 
22.			f[i].id=i+1;
23.			f[i].sum=f[i].a*100000+f[i].b;
24.		}
25.		sort(f,f+n,cmp1);
26.		
27.		for(int i=0;i<m;i++){
28.			if(i==m-1)	cout<<f[i].id<<endl;
29.			else cout<<f[i].id<<" ";
30. 
31.		}
32.		
33.	} 
34.	return 0;
35.} 

/*
Main.cc:2:3: error: stray '#' in program
 2.#include<algorithm>
   ^
Main.cc:2:1: error: expected unqualified-id before numeric constant
 2.#include<algorithm>
 ^
Main.cc:4:1: error: expected unqualified-id before numeric constant
 4.struct node{
 ^
Main.cc:9:4: error: 'f' does not name a type
 9.}f[100000]; 
    ^
Main.cc:10:1: error: expected unqualified-id before numeric constant
 10.bool cmp1(node x,node y){
 ^
Main.cc:13:1: error: expected unqualified-id before numeric constant
 13. 
 ^
*/

Double click to view unformatted code.


Back to problem 5