Educational Codeforces Round 93 (Rated for Div. 2)
C
#include<bits/stdc++.h>
using namespace std;
long long t,n,i,cnt,ans;string str;map<int,int>mp;
int main(){
for(cin>>t; t-- and cin>>n>>str; cout<<ans<<'\n')
for(mp.clear(),mp[0]=1,cnt=ans=i=0; i<n; ans += mp[cnt+=str[i++]-49]++);
//mp[]裡的下標cnt算出來的就是當前位置與之前位置的整個區間的和值與區間長度的差
}
D
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
const int maxn = 205;
int R[maxn],G[maxn],B[maxn];
ll dp[maxn][maxn][maxn];
int main() {
int n1,n2,n3;scanf("%d%d%d",&n1,&n2,&n3);
for(int i = 1;i <= n1;i++) {
scanf("%d",&R[i]);
}
for(int i = 1;i <= n2;i++) {
scanf("%d",&G[i]);
}
for(int i = 1;i <= n3;i++) {
scanf("%d",&B[i]);
}
sort(R + 1,R + 1 + n1);
sort(G + 1,G + 1 + n2);
sort(B + 1,B + 1 + n3);
for(int i = 0;i <= n1;i++) {
for(int j = 0;j <= n2;j++) {
for(int k = 0;k <= n3;k++) {
dp[i + 1][j + 1][k] = max(dp[i + 1][j + 1][k],dp[i][j][k] + R[i + 1] * G[j + 1]);
dp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1],dp[i][j][k] + R[i + 1] * B[k + 1]);
dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1],dp[i][j][k] + G[j + 1] * B[k + 1]);
}
}
}
printf("%lld\n",dp[n1][n2][n3]);
return 0;
}
相關文章
- Educational Codeforces Round 93 (Rated for Div. 2)題解
- Educational Codeforces Round 37 (Rated for Div. 2)
- Educational Codeforces Round 170 (Rated for Div. 2)
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)
- Educational Codeforces Round 100 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2) C
- Educational Codeforces Round 34 (Rated for Div. 2) D
- Educational Codeforces Round 163 (Rated for Div. 2)
- Educational Codeforces Round 154 (Rated for Div. 2)
- Educational Codeforces Round 168 (Rated for Div. 2)
- codeforces Educational Codeforces Round 33 (Rated for Div. 2)B
- Educational Codeforces Round 170 (Rated for Div. 2) A-D
- Educational Codeforces Round 170 (Rated for Div. 2) ABCD
- Educational Codeforces Round 171 (Rated for Div. 2) 題解
- Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Educational Codeforces Round 143 (Rated for Div. 2) A-E
- Educational Codeforces Round 142 (Rated for Div. 2) A-D
- vp Educational Codeforces Round 168 (Rated for Div. 2) A - E
- Educational Codeforces Round 168 (Rated for Div. 2) 題解
- Educational Codeforces Round 95 (Rated for Div. 2) G. Three Occurrences
- Educational Codeforces Round 163 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 166 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 162 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 159 (Rated for Div. 2) - VP記錄
- Educational Codeforces Round 158 (Rated for Div. 2) - VP記錄
- 【CodeForces訓練記錄】Educational Codeforces Round 171 (Rated for Div. 2)
- Educational Codeforces Round 99 (Rated for Div. 2)D. Sequence and Swaps
- Educational Codeforces Round 167 (Rated for Div. 2) D(dp,貪心)
- Educational Codeforces Round 163 (Rated for Div. 2) 補題記錄(A~A)
- Educational Codeforces Round 171 (Div. 2)
- Educational Codeforces Round 98 (Rated for Div. 2) E. Two Editorials 細節題
- Educational Codeforces Round 99 (Rated for Div. 2) D. Sequence and Swaps(貪心)
- [CF1954] Educational Codeforces Round 164 (Rated for Div. 2) 題解
- Educational Codeforces Round 165 (Rated for Div. 2) C. Minimizing the Sum題解
- Educational Codeforces Round 166 (Rated for Div. 2) (補題之抽象的自我審題)抽象
- Educational Codeforces Round 53 (Rated for Div. 2) C. Vasya and Robot 二分+前字尾預處理
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) B
- 21 Educational Codeforces Round 136 (Rated for Div. 2)Knowledge Cards(樹狀陣列、set、+思維、數字華容道)陣列