Problem:
Problem B: GPA JANKEN
Problem
GPAとは「Galaxy Point of Aizu」の略で、0から4までの実数値を取る。
GPAじゃんけんは二人で行うゲームである。各々が「じゃんけん、ぽん（ほい）」の合図で互いにグー、チョキ、パーのどれか好きな手を出した後、GPAが高い人が勝者となり、低い人が敗者となる。同じ場合は引き分けとなる。
N
人のGPAのデータが与えられるので、総当たり戦をした時のそれぞれの勝ち点を出力せよ。
ただし、勝ち点は勝ちの時3、引き分けの時1、負けの時0とする。
総当たり戦とはすべての参加者が自分以外の参加者と丁度一回ずつ対戦する方式である。
Input
入力は以下の形式で与えられる。
N
a
1
a
2
...
a
N
一行目にGPAじゃんけんをする人数
N
が与えられる。
続く
N
行に
i
番目の人のGPAのデータ
a
i
が一行に与えられる。
Constraints
入力は以下の条件を満たす。
2 ≤
N
≤ 10
5
N
は整数
0.000 ≤
a
i
≤ 4.000 ( 1 ≤
i
≤
N
)
a
i
は実数 ( 1 ≤
i
≤
N
)
各GPAは小数点以下3桁まで与えられる
Output
i
行目に
i
番目の人の勝ち点を一行に出力せよ。
  ( 1 ≤
i
≤
N
)
Sample Input 1
3
1.000
3.000
3.000
Sample Output 1
0
4
4
Sample Input 2
3
1.000
2.000
3.000
Sample Output 2
0
3
6

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std;

#define FOR(i,s,t) for(int i = s ; i < t ; i++)
using LL = long long; using ll = LL;
using PII = pair<int, int>; using pii = PII;
using PLL = pair<LL, LL>; using pll = PLL;
const int INF = 1e9;
const float EPS = 1e-9;


int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<pair<float, int>> a;
	vector<pair<int, int>> result(n);
	for (int i = 0; i < n; ++i) {
		pair<float, int> tmp;
		cin >> tmp.first;
		tmp.second = i;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i) {
		auto l = lower_bound(a.begin(), a.end(), pair<float, int>(a[i].first, -1)) - a.begin();
		auto r = upper_bound(a.begin(), a.end(), pair<float, int>(a[i].first, INF)) - a.begin();

		//cout << a[i].first << " " << a[i].second << " " << l << " " << r << endl;
		result[i].second = l * 3 + (r - l - 1) * 1;
		result[i].first = a[i].second;
	}
	sort(result.begin(), result.end());
	for (auto i : result) {
		cout << i.second << endl;
	}

	return 0;

}
accuracy: 1
time_ms: 80
memory_kb: 4820
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int n; cin >> n;
  vector<int> a(n), cnts(5);
  rep(i, n) {
    double m; cin >> m;
    a[i] = m+0.1;
  }
  rep(i, n) cnts[a[i]]++;
  rep(i, n) {
    int ans = 0;
    rep(j, a[i]) {
      ans += cnts[j]*3;
    }
    ans += cnts[a[i]];
    cout << ans-1 << endl;
  }
}
accuracy: 0.0625
time_ms: 50
memory_kb: 3508
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
  int n; cin >> n;
  vector<int> a(n), cnts(5);
  rep(i, n) {
    double m; cin >> m;
    a[i] = m;
  }
  rep(i, n) cnts[a[i]]++;
  rep(i, n) {
    int ans = 0;
    rep(j, a[i]) {
      ans += cnts[j]*3;
    }
    ans += cnts[a[i]];
    cout << ans-1 << endl;
  }
}
accuracy: 0.0625
time_ms: 50
memory_kb: 3420
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin>>n;
  vector<double> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  auto aa=a;
  sort(aa.begin(),aa.end());
  for(int i=0;i<n;i++){
    ll x=aa.end()-upper_bound(aa.begin(),aa.end(),a[i]);
    ll y=aa.end()-lower_bound(aa.begin(),aa.end(),a[i]);
    y=y-x-1;
    x=n-x-y-1;
    cout<<3*x+y<<endl;
  }
}
accuracy: 1
time_ms: 70
memory_kb: 4992
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int N;
    cin>>N;
    vector A(N,0);
    rep(i,N){
        double x;
        cin>>x;
        A[i]=round(x*1000);
    }
    auto B=A;
    sort(B.begin(),B.end());
    rep(i,N){
        cout<<(lower_bound(B.begin(),B.end(),A[i])-B.begin())*2+(upper_bound(B.begin(),B.end(),A[i])-B.begin())-1<<'\n';
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3888
final_rank: 1

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;

void chmin(ll& a, ll b){
  if(a > b)a = b;
}

#include <atcoder/all>
using namespace atcoder;

int main() {

  int n;
  cin >> n;
  vector<int> a(n);
  
  fenwick_tree<int> fw(5000);
  for(int i=0;i<n;++i){
    string s;
    cin >> s;
    
    a[i] = (s[0] - '0') * 1000 + (s[2]-'0') * 100 + (s[3]-'0') * 10 + (s[4] - '0');
    
    fw.add(a[i], 1);
  }
  
  vector<int> res(n);
  for(int i=0;i<n;++i){
    res[i] += 3 * fw.sum(0, a[i]);
    res[i] += 1 * (fw.sum(a[i], a[i] + 1) - 1);
    cout << res[i] << endl;
  }
  
  
    

}
accuracy: 1
time_ms: 40
memory_kb: 4096
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (auto& x : A) cin >> x;
  
  auto B = A;
  
  sort(A.begin(), A.end());
  
  vector<int> ans(N);
  
  for (int i = 0; i < N; i++) {
    double x = B[i];
    cout << (lower_bound(A.begin(), A.end(), x) - A.begin()) * 2 + (upper_bound(A.begin(), A.end(), x) - A.begin()) - 1 << endl;
  }
  
  
}
accuracy: 1
time_ms: 60
memory_kb: 5376
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i = a; i < (b); i++)
#define all(a) (a).begin(), (a).end()

int main(){
  int n;
  cin >> n;
  vector<int> a;
  rep(i,0, n){
    double x;
    cin >> x;
    a.push_back(round(1000*x));
  }
  vector<int> iot(n);
  iota(all(iot), 0);
  sort(all(iot), [&](int i, int j){
    return a[i] < a[j];
  });
  
  int cnt = 0;
  vector<int> ans(n,0);
  rep(I, 0, n){
    if(I == 0 || a[iot[I-1]] != a[iot[I]]){
      rep(i,0,cnt){
        ans[iot[I-1-i]] += cnt-1;
      }
      cnt=0;
    }
    int i = iot[I];
    ans[i] += 3 * (I-cnt);

    cnt++;
  }
  rep(i, 0, cnt){
    ans[iot[n-1-i]] += cnt-1;
  }
  
  rep(i, 0, n) cout << ans[i] << endl;
}
accuracy: 1
time_ms: 50
memory_kb: 4812
final_rank: 7

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<double> A(N);
  for (auto& x : A) cin >> x;
  
  sort(A.begin(), A.end());
  
  vector<int> ans(N);
  
  for (int i = 0; i < N; i++) {
    double x = A[i];
    cout << (lower_bound(A.begin(), A.end(), x) - A.begin()) * 2 + (upper_bound(A.begin(), A.end(), x) - A.begin()) - 1 << endl;
  }
  
  
}
accuracy: 0.0625
time_ms: 30
memory_kb: 4352
final_rank: 18

code_snippet: #include "bits/stdc++.h"

using namespace std;

#define ll long long
#define REP(i, n) for(int i = 0;i < n; i ++)
#define REPR(i, n) for(int i = n;i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define P pair<ll,ll>
int main(){
    ll n;
    cin >> n;
    vector<float> s(n), t(n);
    vector<ll> ans(n);
    
    REP(i, n){
        float a;
        cin >> a;
        s[i] = a;
        t[i] = s[i];
    }
    sort(ALL(s));
    s.push_back(10000);
    REP(i, n){
        ll i1 = lower_bound(ALL(s), t[i]) - s.begin();
        ll i2 = lower_bound(ALL(s), t[i] + 0.0001) - s.begin();
        //cout << i1 <<" " << i2 << " " << s[i] << endl;
        ll now = (i2 - i1 - 1) + i1 * 3;
        ans[i] = now;
    }
    

    REP(i, n)cout << ans[i] << endl;
}
accuracy: 1
time_ms: 100
memory_kb: 4896
final_rank: 13

code_snippet: #include<bits/stdc++.h>
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define all(v) begin(v),end(v)
using namespace std;
using ll = long long;

bool chmin(auto &a, auto b){ return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b){ return a < b ? a = b, 1 : 0; }

bool ispali(int n){
    string s = to_string(n);
    string t = s;
    reverse(all(t));
    return s == t;
}

const int iinf = 1e9;

int main(){
    int n; cin >> n;
    map<string,vector<int>> mp;
    rep(i,0,n){
        string s; cin >> s;
        mp[s].emplace_back(i);
    }
    vector<int> ans(n);
    int pre = 0;
    for (auto [s, ids] : mp){
        int score = pre*3 + ids.size() - 1;
        for (int i : ids){
            ans[i] = score;
        }
        pre += ids.size();
    }
    rep(i,0,n){
        cout << ans[i] << '\n';
    }
}
accuracy: 1
time_ms: 20
memory_kb: 4864
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {

	int n; cin >> n;
	vector<int> a(n);
	vector<int> cnt(5000);
	for (int i=0; i<n; i++) {
		double x; cin >> x;
		a[i] = round(x*1000);
		cnt[a[i]]++;
	}
	for (int i=0; i<4500; i++) {
		cnt[i+1] += cnt[i];
	}
	
	for (int i=0; i<n; i++) {
		ll t = 0;
		t += cnt[a[i]] - 1;
		if (a[i] > 0) {
			t += cnt[a[i]-1] * 3;
			t -= cnt[a[i]-1];
		}
		cout << t << endl;
	}
	
	
}
accuracy: 1
time_ms: 80
memory_kb: 3584
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;
#define endl "\n"
typedef long long ll;
int n;
void solved() {
cin>>n;
map<double ,int> mp;
vector<double> ch(n+1),v(n+1);
for(int i=1;i<=n;i++) cin>>ch[i],v[i]=ch[i];


sort(ch.begin()+1,ch.end());

for(int i=1;i<n;i++) {
while(ch[i+1]==ch[i]&&i+1<=n) {
    mp[ch[i]]++;
    i++;
}
mp[ch[i+1]]+=3*i;
}
for(int i=1;i<=n;i++) cout<<mp[v[i]]<<endl;


}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  /*int t = 1;
  cin >> t;
  while (t--)*/
  solved();

  return 0;
}
accuracy: 0.0625
time_ms: 20
memory_kb: 4336
final_rank: 17

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<string, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v.begin(), v.end());
    vector<int> res(n);
    for (int i = 0; i < n;) {
        int j = i;
        while (i < n and v[j].first == v[i].first) {
            i += 1;
        }
        for (int k = j; k < i; k++) {
            res[v[k].second] += i - j - 1;
            res[v[k].second] += 3 * j;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << res[i] << "\n";
    }
}
accuracy: 1
time_ms: 20
memory_kb: 6856
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    vector<int> D(4001,0),G(N);
    for(int i=0;i<N;i++){
        double g;
        cin>>g;
        G[i]=round(g*1000);
        D[G[i]]++;
    }
    for(int i=0;i<N;i++){
        int sc=D[G[i]]-1;
        for(int j=0;j<G[i];j++){
            sc+=3*D[j];
        }
        cout<<sc<<endl;
    }

}
accuracy: 1
time_ms: 160
memory_kb: 3520
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    vector<int> D(4001,0),G(N);
    for(int i=0;i<N;i++){
        double g;
        cin>>g;
        G[i]=int(g*1000);
        D[G[i]]++;
    }
    for(int i=0;i<N;i++){
        int sc=D[G[i]]-1;
        for(int j=0;j<G[i];j++){
            sc+=3*D[j];
        }
        cout<<sc<<endl;
    }

}
accuracy: 0.0625
time_ms: 90
memory_kb: 3408
final_rank: 20

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, r) for(int i = 0; i < (r); ++i)
#define reps(i, s, r) for(int i = (s); i < (r); ++i)
#define fore(i, m2) for(auto &i : m2)
#define vi vector<int>
#define vl vector<ll>
#define pl pair<ll, ll>
#define all(i) (i).begin(), (i).end()
#define fs first
#define sc second

template <class T> bool chmin(T &i, T b) {
    if(i > b) {
        i = b;
        return true;
    }
    return false;
}
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = LONG_LONG_MAX / 3;
const ll MOD = 1'000'000'007;
const ll MAX = 4005;

int main() {

    ll n;
    cin >> n;

    vl a(n), tmp(MAX), ru(MAX);
    vl pnt(n);
    double d;
    rep(i, n) {
        cin >> d;
        a[i] = (ll)round(d * 1000);
        tmp[a[i]]++;
    }

    rep(j, 4000) { ru[j + 1] = ru[j] + tmp[j]; }

    rep(i, n) {

        pnt[i] += tmp[a[i]] - 1;
        pnt[i] += (ru[a[i]] - ru[0]) * 3;
    }

    rep(i, n) cout << pnt[i] << endl;

    return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 4608
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define rep(i, r) for(int i = 0; i < (r); ++i)
#define reps(i, s, r) for(int i = (s); i < (r); ++i)
#define fore(i, m2) for(auto &i : m2)
#define vi vector<int>
#define vl vector<ll>
#define pl pair<ll, ll>
#define all(i) (i).begin(), (i).end()
#define fs first
#define sc second

template <class T> bool chmin(T &i, T b) {
    if(i > b) {
        i = b;
        return true;
    }
    return false;
}
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll INF = LONG_LONG_MAX / 3;
const ll MOD = 1'000'000'007;
const ll MAX = 4005;

int main() {

    ll n;
    cin >> n;

    vl a(n), tmp(MAX), ru(MAX);
    vl pnt(n);
    double d;
    rep(i, n) {
        cin >> d;
        a[i] = (ll)(d * 1000);
        tmp[a[i]]++;
    }

    rep(j, 4000) { ru[j + 1] = ru[j] + tmp[j]; }

    rep(i, n) {

        pnt[i] += tmp[a[i]] - 1;
        pnt[i] += (ru[a[i]] - ru[0]) * 3;
    }

    rep(i, n) cout << pnt[i] << endl;

    return 0;
}
accuracy: 0.0625
time_ms: 50
memory_kb: 4128
final_rank: 19

code_snippet: #include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX_N = 100000;
double scores[MAX_N], players[MAX_N];
int res[MAX_N];


int main(){

    int n, left, right;
    double t;
    scanf("%d", &n);
    fill(res, res+n, 0);
    for (int i = 0; i < n; i++) {
        scanf("%lf", &t);
        players[i] = scores[i] = t;
    }
    sort(scores, scores+n);
    //for (int i = 0; i < n; i++) printf("%.2lf ", scores[i]);
    //printf("\n");

    for (int i = 0; i < n; i++) {
        left = lower_bound(scores, scores+n, players[i])-scores;
        right = (players[i] == scores[n-1]) ? n-1 : upper_bound(scores, scores+n, players[i])-scores-1;
        res[i] = 3*left + right-left;
    }
    for (int i = 0; i < n; i++) {
        printf("%d\n", res[i]);
    }


    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4932
final_rank: 6

code_snippet: #include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;

    int A[N];
    int GPA[4001]{};

    int a, c;
    char b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b >> c;
        a = a * 1000 + c;
        A[i] = a;
        GPA[a]++;
    }

    for (int i = 1; i <= 4000; i++) {
        GPA[i] += GPA[i - 1];
    }

    int p;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            p = GPA[A[i]] - 1;
        } else {
            p = GPA[A[i] - 1] * 3;
            p += GPA[A[i]] - GPA[A[i] - 1] - 1;
        }
        cout << p << endl;
    }
}
accuracy: 1
time_ms: 100
memory_kb: 3436
final_rank: 5