Skip to content

Commit ce2e8db

Browse files
committed
the rank
1 parent 64261d2 commit ce2e8db

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

Free/C_theRank.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <bits/stdc++.h>
2+
#define all(x) x.begin(),x.end()
3+
#define msg(str,str2) cout << str << str2<< endl
4+
using namespace std;
5+
6+
using ll = long long;
7+
using ld = long double;
8+
using uint = unsigned int;
9+
using ull = unsigned long long;
10+
template<typename T>
11+
using pair2 = pair<T, T>;
12+
using pii = pair<int, int>;
13+
using pli = pair<ll, int>;
14+
using pll = pair<ll, ll>;
15+
16+
#define pb push_back
17+
#define mp make_pair
18+
19+
int gcd(int a,int b){
20+
if(a%b==0) return b;
21+
else return gcd(b,a%b);
22+
}
23+
24+
clock_t startTime;
25+
double getCurrentTime() {
26+
return (double)(clock() - startTime) / CLOCKS_PER_SEC;
27+
}
28+
bool cmp(pii &a, pii &b){
29+
if(b.first == a.first){
30+
return a.second < b.second;
31+
}else return a.first > b.first;
32+
}
33+
void solve(){
34+
int n; cin>>n;
35+
int temp;
36+
vector<pii> vec;
37+
for(int e = 1 ; e <= n; e++){
38+
int sum = 0;
39+
for(int j = 0 ; j < 4; j++){
40+
cin>>temp;
41+
sum += temp;
42+
}
43+
vec.pb({sum,e});
44+
}
45+
sort(all(vec), cmp);
46+
// cout << "print pairs" << endl;
47+
// for(int e = 0 ; e < n;e++){
48+
// cout << vec[e].first << " " <<vec[e].second << endl;
49+
// }
50+
for(int e = 0 ; e < n; e++){
51+
if(vec[e].second == 1){cout << e+1 << endl;return;}
52+
}
53+
}
54+
int main(){
55+
ios_base::sync_with_stdio(false);
56+
cin.tie(0);
57+
solve();
58+
return 0;
59+
}

0 commit comments

Comments
 (0)