Submission #73697705
Source Code Expand
#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); ++i)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
int gcd(int a, int b){
if(b == 0) return a;
else return gcd(b, a%b);
}
struct Compare {
bool operator()(const pair<ll, int>& a, const pair<ll, int>& b) {
return a.first > b.first;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s; cin >> s;
set<int> a,b,c;
rep(i,(int)s.size()){
if(s[i] == 'A') a.insert(i);
if(s[i] == 'B') b.insert(i);
if(s[i] == 'C') c.insert(i);
}
int ans = 0;
for(auto x:a){
auto it = b.lower_bound(x);
if(it == b.end()) break;
int num = *it;
auto it2 = c.lower_bound(num);
if(it2 == c.end()) break;
ans++;
b.erase(it);
c.erase(it2);
}
cout << ans << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Take ABC 2 |
| User | motomoto0001 |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 1187 Byte |
| Status | AC |
| Exec Time | 245 ms |
| Memory | 51276 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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_test_00.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, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 02_corner_00.txt, 02_corner_01.txt, 02_corner_02.txt, 02_corner_03.txt, 02_corner_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 3676 KiB |
| 00_sample_01.txt | AC | 1 ms | 3556 KiB |
| 00_sample_02.txt | AC | 1 ms | 3460 KiB |
| 01_test_00.txt | AC | 1 ms | 3612 KiB |
| 01_test_01.txt | AC | 1 ms | 3536 KiB |
| 01_test_02.txt | AC | 1 ms | 3536 KiB |
| 01_test_03.txt | AC | 141 ms | 44396 KiB |
| 01_test_04.txt | AC | 113 ms | 35920 KiB |
| 01_test_05.txt | AC | 146 ms | 44912 KiB |
| 01_test_06.txt | AC | 169 ms | 51156 KiB |
| 01_test_07.txt | AC | 169 ms | 51152 KiB |
| 01_test_08.txt | AC | 166 ms | 51184 KiB |
| 01_test_09.txt | AC | 166 ms | 51156 KiB |
| 01_test_10.txt | AC | 166 ms | 51272 KiB |
| 01_test_11.txt | AC | 161 ms | 51276 KiB |
| 01_test_12.txt | AC | 162 ms | 51168 KiB |
| 01_test_13.txt | AC | 160 ms | 51160 KiB |
| 01_test_14.txt | AC | 148 ms | 51240 KiB |
| 01_test_15.txt | AC | 150 ms | 51152 KiB |
| 01_test_16.txt | AC | 147 ms | 51156 KiB |
| 01_test_17.txt | AC | 187 ms | 51236 KiB |
| 01_test_18.txt | AC | 152 ms | 51156 KiB |
| 01_test_19.txt | AC | 177 ms | 51176 KiB |
| 01_test_20.txt | AC | 184 ms | 51180 KiB |
| 01_test_21.txt | AC | 177 ms | 51224 KiB |
| 01_test_22.txt | AC | 160 ms | 51168 KiB |
| 01_test_23.txt | AC | 179 ms | 51224 KiB |
| 01_test_24.txt | AC | 173 ms | 51276 KiB |
| 01_test_25.txt | AC | 182 ms | 51244 KiB |
| 01_test_26.txt | AC | 179 ms | 51220 KiB |
| 02_corner_00.txt | AC | 227 ms | 51156 KiB |
| 02_corner_01.txt | AC | 219 ms | 51172 KiB |
| 02_corner_02.txt | AC | 243 ms | 51232 KiB |
| 02_corner_03.txt | AC | 245 ms | 51148 KiB |
| 02_corner_04.txt | AC | 243 ms | 51232 KiB |