mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Update: Rename folder name to XSMOJ
This commit is contained in:
35
XSMOJ/长方形排序.cpp
Normal file
35
XSMOJ/长方形排序.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
typedef long long l;
|
||||
typedef double d;
|
||||
typedef char c;
|
||||
using namespace std;
|
||||
struct rect{
|
||||
int c;
|
||||
int k;
|
||||
int id;
|
||||
}arr[10000];
|
||||
bool cmp(rect a,rect b){
|
||||
if(a.c+a.k==b.c+b.k){
|
||||
return a.c<b.c;
|
||||
}
|
||||
return a.c+a.k>b.c+b.k;
|
||||
}
|
||||
int main(){
|
||||
int a;
|
||||
cin >>a;
|
||||
for(int i=0;i<a;i++){
|
||||
cin >>arr[i].c>>arr[i].k;
|
||||
arr[i].id=i;
|
||||
}
|
||||
sort(arr,arr+a,cmp);
|
||||
for(int i=0;i<a;i++){
|
||||
cout <<arr[i].id+1<<" ";
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user