提出 #61564262


ソースコード 拡げる

/*

    कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
    मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥

*/
/* Author: BitWizz */

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace chrono;
using namespace __gnu_pbds;

#define solveT() {int tc; cin >> tc; while (tc--) solve();} // if tc given
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int int64_t
#define nline "\n"
#define inf 1e18
#define pb push_back
#define ppb pop_back
#define set_bits(x) __builtin_popcountll(x)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
const int mod = 1e9 + 7;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds;
/* find_by_order(K): Returns an iterator to the Kth largest element (counting from zero) */
/* order_of_key (K): Returns the number of items that are strictly smaller than K */

/*----------------------------------------------Debug Template -------------------------------------------------------------*/
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x<<" "; _print(x); cerr << endl;
#else
#define debug(x);
#endif

void _print(int t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
void _print(pbds v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*---------------------------------------------------------------------------------------------------------------------------*/
int mod_add (int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul (int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub (int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int gcd (int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo (int a, int b, int mod) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd (int a, int b, int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3
int mminv (int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
int mminvprime (int a, int b) {return expo(a, b - 2, b);}
bool revsort(int a, int b) {return a > b;}
int mod_div (int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m
void swap (int &x, int &y) {int temp = x; x = y; y = temp;}
int combination (int n, int r, int m, int *fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
int getRandomNumber (int l, int r) {return uniform_int_distribution<int>(l, r)(rng);}
void mhc (int t) {cout << "Case #" << t << ": ";}
/*---------------------------------------------------------------------------------------------------------------------------*/

int f(int n, vector<int>&a) {
    int i = 0, j = n / 2, cnt = 0;
    while (i < n / 2 && j < n) {
        if (a[i] <= a[j] / 2) {
            cnt++;
            i++;
            j++;
        }
        else j++;
    }
    return cnt;
}

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &x : a)
        cin >> x;
    cout << f(n, a) << nline;
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio();
    auto start1 = high_resolution_clock::now();
    solve();
    auto stop1 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000 << endl;
#endif
    return 0;
}

提出情報

提出日時
問題 E - Simultaneous Kagamimochi
ユーザ BitWizz
言語 C++ 23 (gcc 12.2)
得点 450
コード長 5326 Byte
結果 AC
実行時間 28 ms
メモリ 7164 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 41
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 02_handmade_36.txt, 02_handmade_37.txt, 02_handmade_38.txt, 02_handmade_39.txt, 02_handmade_40.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3468 KiB
00_sample_01.txt AC 1 ms 3488 KiB
00_sample_02.txt AC 1 ms 3464 KiB
01_random_03.txt AC 28 ms 7016 KiB
01_random_04.txt AC 28 ms 7000 KiB
01_random_05.txt AC 27 ms 7004 KiB
01_random_06.txt AC 27 ms 7028 KiB
01_random_07.txt AC 27 ms 7092 KiB
01_random_08.txt AC 4 ms 3624 KiB
01_random_09.txt AC 27 ms 7100 KiB
01_random_10.txt AC 16 ms 5260 KiB
01_random_11.txt AC 27 ms 7008 KiB
01_random_12.txt AC 28 ms 7000 KiB
01_random_13.txt AC 26 ms 7000 KiB
01_random_14.txt AC 28 ms 7096 KiB
01_random_15.txt AC 27 ms 7108 KiB
01_random_16.txt AC 26 ms 7012 KiB
01_random_17.txt AC 28 ms 7024 KiB
01_random_18.txt AC 27 ms 7164 KiB
01_random_19.txt AC 27 ms 7088 KiB
01_random_20.txt AC 28 ms 6988 KiB
01_random_21.txt AC 27 ms 6936 KiB
01_random_22.txt AC 28 ms 7012 KiB
01_random_23.txt AC 28 ms 7000 KiB
01_random_24.txt AC 27 ms 7012 KiB
01_random_25.txt AC 27 ms 7096 KiB
01_random_26.txt AC 28 ms 7164 KiB
01_random_27.txt AC 28 ms 7056 KiB
01_random_28.txt AC 26 ms 7100 KiB
01_random_29.txt AC 26 ms 7044 KiB
01_random_30.txt AC 26 ms 7036 KiB
01_random_31.txt AC 27 ms 7104 KiB
01_random_32.txt AC 26 ms 7060 KiB
01_random_33.txt AC 16 ms 5188 KiB
01_random_34.txt AC 21 ms 6252 KiB
01_random_35.txt AC 17 ms 5452 KiB
02_handmade_36.txt AC 1 ms 3488 KiB
02_handmade_37.txt AC 1 ms 3324 KiB
02_handmade_38.txt AC 23 ms 7072 KiB
02_handmade_39.txt AC 28 ms 7164 KiB
02_handmade_40.txt AC 16 ms 7164 KiB