Submission #72216878
Source Code Expand
#include<bits/stdc++.h>
#define int long long
//#define MSOD
//#define READ_IN_FILE
#define endl '\n'
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 3e5 + 10, P = 998244353, MOD = 1e9 + 7, inf = 0x3f3f3f3f;
bool cmpbig(int i, int j)
{
return i > j;
}
double mylog(int x, int y)
{
return log(x) / log(y);
}
long long qpow(long long a, long long b, long long mod = LLONG_MAX)
{
long long num = 1;
while (b)
{
if (b & 1)num = num * a % mod;
a = a * a % mod;
b >>= 1;
}
return num;
}
int n, ans,a[N];
map<int, vector<int>> mp;
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i],mp[a[i]].push_back(i);
for (auto e : mp)
{
if (e.first % 5 != 0) continue;
int t = e.first / 5, x = 7 * t, z = 3 * t;
if (!mp.count(x) || !mp.count(z)) continue;
for (int p : e.second)
{
int rx = mp[x].end() - upper_bound(mp[x].begin(), mp[x].end(), p), rz = mp[z].end() - upper_bound(mp[z].begin(), mp[z].end(), p);
int lx = lower_bound(mp[x].begin(), mp[x].end(), p) - mp[x].begin(), lz = lower_bound(mp[z].begin(), mp[z].end(), p) - mp[z].begin();
ans += rx * rz + lx * lz;
}
}
cout << ans;
return;
}
signed main()
{
FAST
#ifdef READ_IN_FILE
freopen(".in", "r", stdin);
freopen(".out", "w", stdout);
#endif
int _T_ = 1;
#ifdef MSOD
cin >> _T_;
#endif
while (_T_--)solve();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Kadomatsu Subsequence |
| User | Little_Cck |
| Language | C++23 (GCC 15.2.0) |
| Score | 425 |
| Code Size | 1439 Byte |
| Status | AC |
| Exec Time | 229 ms |
| Memory | 38812 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 425 / 425 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt, sample_03.txt |
| All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample_01.txt | AC | 1 ms | 3456 KiB |
| sample_02.txt | AC | 1 ms | 3612 KiB |
| sample_03.txt | AC | 1 ms | 3416 KiB |
| test_01.txt | AC | 1 ms | 3588 KiB |
| test_02.txt | AC | 1 ms | 3544 KiB |
| test_03.txt | AC | 1 ms | 3400 KiB |
| test_04.txt | AC | 1 ms | 3616 KiB |
| test_05.txt | AC | 24 ms | 8900 KiB |
| test_06.txt | AC | 24 ms | 8948 KiB |
| test_07.txt | AC | 22 ms | 8788 KiB |
| test_08.txt | AC | 23 ms | 8972 KiB |
| test_09.txt | AC | 25 ms | 8880 KiB |
| test_10.txt | AC | 24 ms | 8964 KiB |
| test_11.txt | AC | 22 ms | 10500 KiB |
| test_12.txt | AC | 39 ms | 10212 KiB |
| test_13.txt | AC | 24 ms | 10260 KiB |
| test_14.txt | AC | 31 ms | 9788 KiB |
| test_15.txt | AC | 34 ms | 9468 KiB |
| test_16.txt | AC | 43 ms | 10080 KiB |
| test_17.txt | AC | 27 ms | 8824 KiB |
| test_18.txt | AC | 44 ms | 9096 KiB |
| test_19.txt | AC | 33 ms | 8824 KiB |
| test_20.txt | AC | 91 ms | 11036 KiB |
| test_21.txt | AC | 56 ms | 9580 KiB |
| test_22.txt | AC | 88 ms | 10824 KiB |
| test_23.txt | AC | 132 ms | 18048 KiB |
| test_24.txt | AC | 159 ms | 19524 KiB |
| test_25.txt | AC | 144 ms | 17204 KiB |
| test_26.txt | AC | 225 ms | 38676 KiB |
| test_27.txt | AC | 225 ms | 38792 KiB |
| test_28.txt | AC | 224 ms | 38792 KiB |
| test_29.txt | AC | 227 ms | 38812 KiB |
| test_30.txt | AC | 229 ms | 38796 KiB |