Submission #2501763
Source Code Expand
#include <bits/stdc++.h> // iostream is too mainstream #include <cstdio> // bitch please #include <iostream> #include <algorithm> #include <cstdlib> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <cmath> #include <iomanip> #include <time.h> #define dibs reserve #define OVER9000 1234567890 #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++) #define tisic 47 #define soclose 1e-8 #define chocolate win // so much chocolate #define patkan 9 #define ff first #define ss second #define abs(x) ((x < 0)?-(x):x) #define uint unsigned int #define dbl long double #define pi 3.14159265358979323846 using namespace std; // mylittledoge typedef long long cat; #ifdef DONLINE_JUDGE // palindromic tree is better than splay tree! #define lld I64d #endif int main() { cin.sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10); int N; cin >> N; vector<int> A(2*N); vector<char> C(2*N); for(int i = 0; i < 2*N; i++) cin >> C[i] >> A[i]; vector< vector<int> > pos(2, vector<int>(N)); for(int i = 0; i < 2*N; i++) pos[C[i] == 'B'][A[i]-1] = i; vector< vector<int> > cnt[2]; for(int k = 0; k < 2; k++) { cnt[k].resize(N+1, vector<int>(2*N+1, 0)); for(int i = 0; i < 2*N; i++) if((C[i] == 'B') == k) for(int j = 0; j <= A[i]-1; j++) cnt[k][j][i+1] = 1; for(int j = 0; j < N; j++) for(int i = 0; i < 2*N; i++) cnt[k][j][i+1] += cnt[k][j][i]; } vector< vector<int> > mincost(N+1, vector<int>(N+1, OVER9000)); mincost[0][0] = 0; for(int i = 0; i <= N; i++) for(int j = 0; j <= N; j++) { if(i < N) { int p = pos[0][i]; mincost[i+1][j] = min(mincost[i+1][j], mincost[i][j] + cnt[0][i][p] + cnt[1][j][p]); } if(j < N) { int p = pos[1][j]; mincost[i][j+1] = min(mincost[i][j+1], mincost[i][j] + cnt[0][i][p] + cnt[1][j][p]); } } cout << mincost[N][N] << "\n"; return 0;} // look at my code // my code is amazing
Submission Info
Submission Time | |
---|---|
Task | E - Sorted and Sorted |
User | xellos |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 2024 Byte |
Status | AC |
Exec Time | 249 ms |
Memory | 78720 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | AC | 1 ms | 256 KB |
1_003.txt | AC | 1 ms | 256 KB |
1_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | AC | 1 ms | 256 KB |
1_010.txt | AC | 1 ms | 256 KB |
1_011.txt | AC | 1 ms | 256 KB |
1_012.txt | AC | 1 ms | 256 KB |
1_013.txt | AC | 1 ms | 256 KB |
1_014.txt | AC | 183 ms | 61568 KB |
1_015.txt | AC | 16 ms | 9344 KB |
1_016.txt | AC | 136 ms | 45824 KB |
1_017.txt | AC | 42 ms | 19072 KB |
1_018.txt | AC | 1 ms | 512 KB |
1_019.txt | AC | 10 ms | 6528 KB |
1_020.txt | AC | 148 ms | 53632 KB |
1_021.txt | AC | 44 ms | 21120 KB |
1_022.txt | AC | 20 ms | 11136 KB |
1_023.txt | AC | 119 ms | 46336 KB |
1_024.txt | AC | 202 ms | 75776 KB |
1_025.txt | AC | 249 ms | 78720 KB |
1_026.txt | AC | 242 ms | 78720 KB |
1_027.txt | AC | 240 ms | 78720 KB |
1_028.txt | AC | 240 ms | 78720 KB |
1_029.txt | AC | 240 ms | 78720 KB |
1_030.txt | AC | 241 ms | 78720 KB |
1_031.txt | AC | 243 ms | 78720 KB |
1_032.txt | AC | 212 ms | 78720 KB |
1_033.txt | AC | 215 ms | 78720 KB |
1_034.txt | AC | 218 ms | 78720 KB |
1_035.txt | AC | 219 ms | 78720 KB |