Submission #61555626


Source Code Expand

/*

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

*/
/* 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 << ": ";}
/*---------------------------------------------------------------------------------------------------------------------------*/

void solve() {
    int N; cin >> N;
    vector<int> A(N);
    for (auto &x : A)
        cin >> x;
    int cnt = 0;
    for (int j = 1; j < N; ++j) {
        auto it = lower_bound(A.begin(), A.begin() + j, (A[j] + 2) / 2);
        cnt += (it - A.begin());
    }
    cout << cnt << 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;
}

Submission Info

Submission Time
Task C - Various Kagamimochi
User BitWizz
Language C++ 23 (gcc 12.2)
Score 300
Code Size 5241 Byte
Status AC
Exec Time 38 ms
Memory 7248 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 30
Set Name Test Cases
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, 02_handmade_23.txt, 02_handmade_24.txt, 02_handmade_25.txt, 02_handmade_26.txt, 02_handmade_27.txt, 02_handmade_28.txt, 02_handmade_29.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3532 KiB
00_sample_01.txt AC 1 ms 3540 KiB
00_sample_02.txt AC 1 ms 3540 KiB
01_random_03.txt AC 37 ms 7076 KiB
01_random_04.txt AC 37 ms 7084 KiB
01_random_05.txt AC 36 ms 7028 KiB
01_random_06.txt AC 37 ms 7056 KiB
01_random_07.txt AC 37 ms 7100 KiB
01_random_08.txt AC 36 ms 7148 KiB
01_random_09.txt AC 37 ms 7248 KiB
01_random_10.txt AC 20 ms 5260 KiB
01_random_11.txt AC 12 ms 4504 KiB
01_random_12.txt AC 6 ms 3732 KiB
01_random_13.txt AC 37 ms 7028 KiB
01_random_14.txt AC 36 ms 7064 KiB
01_random_15.txt AC 36 ms 7024 KiB
01_random_16.txt AC 38 ms 7108 KiB
01_random_17.txt AC 38 ms 7140 KiB
01_random_18.txt AC 38 ms 7112 KiB
01_random_19.txt AC 1 ms 3608 KiB
01_random_20.txt AC 1 ms 3508 KiB
01_random_21.txt AC 1 ms 3536 KiB
01_random_22.txt AC 1 ms 3668 KiB
02_handmade_23.txt AC 33 ms 7080 KiB
02_handmade_24.txt AC 12 ms 4436 KiB
02_handmade_25.txt AC 27 ms 6360 KiB
02_handmade_26.txt AC 4 ms 3600 KiB
02_handmade_27.txt AC 28 ms 7052 KiB
02_handmade_28.txt AC 32 ms 7092 KiB
02_handmade_29.txt AC 21 ms 7148 KiB