Submission #49550034
Source Code Expand
#include <bits/stdc++.h>
typedef long long valueType;
typedef std::vector<valueType> ValueVector;
typedef std::vector<ValueVector> ValueMatrix;
typedef std::vector<ValueMatrix> ValueCube;
typedef std::string string;
typedef std::vector<string> StringVector;
typedef std::vector<bool> bitset;
typedef std::vector<bitset> BitMatrix;
typedef std::pair<valueType, valueType> ValuePair;
typedef std::vector<ValuePair> PairVector;
typedef std::vector<PairVector> PairMatrix;
typedef std::tuple<valueType, valueType, valueType> ValueTuple;
typedef std::vector<ValueTuple> TupleVector;
typedef std::vector<TupleVector> TupleMatrix;
typedef std::set<valueType> ValueSet;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
valueType N;
std::cin >> N;
ValueVector A(N + 1);
for (valueType i = 1; i <= N; ++i)
std::cin >> A[i];
ValueVector FirstPos(11, -1);
ValueMatrix SecondPos(11, ValueVector(11, -1));
valueType ans = 0;
valueType l = -1;
for (valueType i = 1; i <= N; ++i) {
for (valueType j = 1; j <= 10; ++j) {
valueType const diff = A[i] - j;
valueType const first = j - diff;
if (first < 1 || first > 10)
continue;
l = std::max(l, SecondPos[j][first]);
}
if (l != -1)
ans += l;
for (valueType j = 1; j <= 10; ++j)
SecondPos[A[i]][j] = std::max(SecondPos[A[i]][j], FirstPos[j]);
FirstPos[A[i]] = i;
}
std::cout << ans << std::endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - Arithmetic Progression Subsequence |
| User | UserUnauthorized |
| Language | C++ 20 (gcc 12.2) |
| Score | 500 |
| Code Size | 1665 Byte |
| Status | AC |
| Exec Time | 6 ms |
| Memory | 3928 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3396 KiB |
| 00_sample_02.txt | AC | 1 ms | 3480 KiB |
| 00_sample_03.txt | AC | 1 ms | 3412 KiB |
| 01_test_01.txt | AC | 1 ms | 3420 KiB |
| 01_test_02.txt | AC | 1 ms | 3420 KiB |
| 01_test_03.txt | AC | 5 ms | 3664 KiB |
| 01_test_04.txt | AC | 5 ms | 3860 KiB |
| 01_test_05.txt | AC | 4 ms | 3664 KiB |
| 01_test_06.txt | AC | 6 ms | 3872 KiB |
| 01_test_07.txt | AC | 6 ms | 3784 KiB |
| 01_test_08.txt | AC | 6 ms | 3928 KiB |
| 01_test_09.txt | AC | 6 ms | 3796 KiB |
| 01_test_10.txt | AC | 6 ms | 3776 KiB |
| 01_test_11.txt | AC | 6 ms | 3820 KiB |
| 01_test_12.txt | AC | 6 ms | 3872 KiB |
| 01_test_13.txt | AC | 6 ms | 3780 KiB |
| 01_test_14.txt | AC | 6 ms | 3792 KiB |
| 01_test_15.txt | AC | 6 ms | 3840 KiB |
| 02_handmade_01.txt | AC | 5 ms | 3868 KiB |
| 02_handmade_02.txt | AC | 5 ms | 3872 KiB |
| 02_handmade_03.txt | AC | 5 ms | 3704 KiB |
| 02_handmade_04.txt | AC | 5 ms | 3824 KiB |
| 02_handmade_05.txt | AC | 5 ms | 3840 KiB |
| 02_handmade_06.txt | AC | 5 ms | 3796 KiB |
| 02_handmade_07.txt | AC | 5 ms | 3828 KiB |
| 02_handmade_08.txt | AC | 5 ms | 3792 KiB |