We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 22f6a91 + 2557d17 commit 29444b9Copy full SHA for 29444b9
khj20006/202601/02 BOJ G5 간판 만들기.md
@@ -0,0 +1,29 @@
1
+```cpp
2
+#include <bits/stdc++.h>
3
+using namespace std;
4
+using ll = long long;
5
+
6
+const ll INF = 1e18;
7
+const string S = "UOSPC";
8
9
+int N;
10
+string s;
11
+ll arr[300000]{};
12
13
+int main() {
14
+ cin.tie(0)->sync_with_stdio(0);
15
16
+ cin>>N>>s;
17
+ for(int i=0;i<N;i++) cin>>arr[i];
18
19
+ vector<ll> res(5, INF);
20
+ for(int i=0;i<N;i++) {
21
+ for(int j=0;j<5;j++) if(s[i] == S[j]) {
22
+ if(!j) res[j] = min(res[j], arr[i]);
23
+ else res[j] = min(res[j], res[j-1] + arr[i]);
24
+ }
25
26
+ cout<<(res[4] == INF ? -1 : res[4]);
27
28
+}
29
+```
0 commit comments