Submission #61561916


Source Code Expand

Copy
/* -------------------------------------- HEADER FILES ---------------------------------------- */
/**
* username: aditya_0670
* created: 2025-01-04 01:53:22
**/
#include <bits/stdc++.h>
using namespace std;
/* ------------------------------------ MACROS & CONSTANTS ------------------------------------ */
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...) ;
#endif
#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/* -------------------------------------- HEADER FILES ---------------------------------------- */

/**
 *    username:  aditya_0670
 *    created: 2025-01-04 01:53:22
 **/

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

/* ------------------------------------ MACROS & CONSTANTS ------------------------------------ */

  #ifndef ONLINE_JUDGE
      #include "debug.h"
  #else
      #define debug(...) ;
  #endif

  #define int             long long
  #define all(v)          (v).begin(), (v).end()
  #define rall(v)         (v).rbegin(), (v).rend()
  #define fastio          ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

  constexpr int MOD = 1E9 + 7;
  constexpr int INF = 1E18;


/* ------------------------------------ OTHER FUNCTIONS ------------------------------------ */


/* ------------------------------------ LAMBDA TEMPLATE ------------------------------------- */

  auto solve = [] -> void
  {
      int n; cin >> n;

      vector<int> a(n);
      for (auto &x : a) cin >> x;

      auto findNextIndex = [&](int i) -> int
      {
           int lo = i, hi = n - 1, res = n;
           while (lo <= hi)
           {
               int mid = lo + (hi - lo) / 2;
               if (a[mid] >= 2 * a[i]) res = mid, hi = mid - 1;
               else lo = mid + 1;
           }
           return res;
      };

      int ans = 0;
      for (int i = 0; i < n; i++)
          ans += (n - findNextIndex(i));

      cout << ans << '\n';
  };

/* ------------------------------------ MAIN FUNCTION --------------------------------------- */

  signed main() 
  {
      fastio;

      int t = 1;
      while (t--) solve();

      return 0;
  }

Submission Info

Submission Time
Task C - Various Kagamimochi
User aditya_0670
Language C++ 23 (gcc 12.2)
Score 300
Code Size 1744 Byte
Status AC
Exec Time 45 ms
Memory 7168 KB

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 3376 KB
00_sample_01.txt AC 1 ms 3392 KB
00_sample_02.txt AC 1 ms 3512 KB
01_random_03.txt AC 44 ms 6980 KB
01_random_04.txt AC 44 ms 7068 KB
01_random_05.txt AC 44 ms 6924 KB
01_random_06.txt AC 44 ms 7000 KB
01_random_07.txt AC 44 ms 6952 KB
01_random_08.txt AC 44 ms 7164 KB
01_random_09.txt AC 44 ms 6964 KB
01_random_10.txt AC 24 ms 5136 KB
01_random_11.txt AC 15 ms 4352 KB
01_random_12.txt AC 9 ms 3564 KB
01_random_13.txt AC 42 ms 6956 KB
01_random_14.txt AC 42 ms 7076 KB
01_random_15.txt AC 42 ms 6968 KB
01_random_16.txt AC 44 ms 7168 KB
01_random_17.txt AC 44 ms 7000 KB
01_random_18.txt AC 45 ms 7072 KB
01_random_19.txt AC 1 ms 3496 KB
01_random_20.txt AC 2 ms 3428 KB
01_random_21.txt AC 1 ms 3504 KB
01_random_22.txt AC 1 ms 3508 KB
02_handmade_23.txt AC 39 ms 6996 KB
02_handmade_24.txt AC 14 ms 4356 KB
02_handmade_25.txt AC 32 ms 6240 KB
02_handmade_26.txt AC 4 ms 3648 KB
02_handmade_27.txt AC 40 ms 6984 KB
02_handmade_28.txt AC 35 ms 6924 KB
02_handmade_29.txt AC 24 ms 7004 KB


2025-03-05 (Wed)
20:49:41 +00:00