結果

問題 No.322 Geometry Dash
ユーザー parukiparuki
提出日時 2016-06-29 19:20:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 2,490 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 171,056 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 06:09:14
合計ジャッジ時間 5,855 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 32 ms
6,940 KB
testcase_05 AC 40 ms
6,940 KB
testcase_06 AC 42 ms
6,944 KB
testcase_07 AC 42 ms
6,940 KB
testcase_08 AC 42 ms
6,940 KB
testcase_09 AC 40 ms
6,940 KB
testcase_10 AC 41 ms
6,940 KB
testcase_11 AC 42 ms
6,944 KB
testcase_12 AC 44 ms
6,940 KB
testcase_13 AC 44 ms
6,940 KB
testcase_14 AC 43 ms
6,944 KB
testcase_15 AC 43 ms
6,944 KB
testcase_16 AC 43 ms
6,940 KB
testcase_17 AC 45 ms
6,944 KB
testcase_18 AC 44 ms
6,944 KB
testcase_19 AC 42 ms
6,944 KB
testcase_20 AC 42 ms
6,940 KB
testcase_21 AC 44 ms
6,940 KB
testcase_22 AC 44 ms
6,944 KB
testcase_23 AC 44 ms
6,944 KB
testcase_24 AC 43 ms
6,940 KB
testcase_25 AC 43 ms
6,944 KB
testcase_26 AC 45 ms
6,948 KB
testcase_27 AC 43 ms
6,940 KB
testcase_28 AC 44 ms
6,940 KB
testcase_29 AC 35 ms
6,940 KB
testcase_30 AC 39 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In member function 'Fraction& Fraction::operator+=(const Fraction&)':
main.cpp:32:5: warning: no return statement in function returning non-void [-Wreturn-type]
   31 |         adjust();
  +++ |+        return *this;
   32 |     }
      |     ^
main.cpp: In member function 'Fraction& Fraction::operator*=(const Fraction&)':
main.cpp:50:5: warning: no return statement in function returning non-void [-Wreturn-type]
   49 |         adjust();
  +++ |+        return *this;
   50 |     }
      |     ^

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

struct Fraction{
    long long n, d;
    Fraction():n(0),d(1){ }
    Fraction(long long n_, long long d_ = 1):n(n_), d(d_){ adjust(); }
    bool operator<(const Fraction &x) const{ return n*x.d < x.n*d; }
    bool operator<=(const Fraction &x) const { return n*x.d<=x.n*d; }
    bool operator>(const Fraction &x) const{ return !(*this<=x); }
    bool operator>=(const Fraction &x) const{ return !(*this<x); }
    bool operator==(const Fraction &x) const{ return n*x.d==x.n*d; }
    bool operator!=(const Fraction &x) const{ return n*x.d!=x.n*d; }
    Fraction & operator+=(const Fraction &x){
        n = x.d*n + d * x.n;
        d *= x.d;
        adjust();
    }
    Fraction operator+(const Fraction &x) const{
        Fraction res = *this;
        res += x;
        return res;
    }
    Fraction & operator-=(const Fraction &x){
        return *this += Fraction(-x.n, x.d);
    }
    Fraction operator-(const Fraction &x) const{
        Fraction res = *this;
        res -= x;
        return res;
    }
    Fraction & operator*=(const Fraction &x){
        n *= x.n;
        d *= x.d;
        adjust();
    }
    Fraction operator*(const Fraction &x) const{
        Fraction res = *this;
        res *= x;
        return res;
    }
    Fraction operator/=(const Fraction &x){
        return *this *= Fraction(x.d, x.n);
    }
    Fraction operator/(const Fraction &x) const{
        Fraction res;
        res /= x;
        return res;
    }
private:
    void adjust(){
        if(n == 0)d = 1;
        if(d < 0)n = -n, d = -d;
        auto g = gcd(n, d);
        n /= g;
        d /= g;
    }
    long long gcd(long long a, long long b){ return b ? gcd(b, a%b) : a; }
};

int main(){
    int N;
    cin>>N;
    vector<pair<Fraction, int>> vf(N);
    rep(i, N)scanf("%lld", &vf[i].first.n);
    rep(i, N)scanf("%lld", &vf[i].first.d), vf[i].second = i + 1;
    sort(all(vf), greater<pair<Fraction, int>>());
    rep(i, N)printf("%d%c", vf[i].second, i == N - 1 ? '\n' : ' ');
}
0