• Educational Codeforces Round 93 (Rated for Div. 2)


    A

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
    ll a[N];
     
    int main() {
        IO;
        for (cin >> _; _; --_) {
            cin >> n;
    		rep (i, 1, n) cin >> a[i];
    		if ((ll)a[1] + a[2] <= a[n]) cout << "1 2 " << n << '
    ';
    		else cout << "-1
    ";
        }
        return 0;
    }
    

    B

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
     
    int main() {
        IO;
        for (cin >> _; _; --_) {
            string s; cin >> s;
    		VI a;
    		int cnt = 0;
    		for (char i : s) {
    			if (i == '1') ++cnt;
    			else if (cnt) a.pb(cnt), cnt = 0;
    		}
     
    		if (cnt) a.pb(cnt);
     
    		sort(all(a));
    		ll ans = 0;
    		for (int i = 1; ; ++i) {
    			if (a.empty()) break;
    			if (i & 1) ans += a.back();
    			a.pop_back();
    		}
    		cout << ans << '
    ';
        }
        return 0;
    }
    

    C

    统计前缀和出现次数, 对应区间就是 0

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
     
    const int N = 1e5 + 5;
     
    int n, m, _, k;
    ll ans;
    string s;
     
    int main() {
    	IO;
    	for (cin >> _; _; --_) {
    		cin >> n >> s;
    		map<int, int> st; st[0] = 1;
    		ll res = 0, ans = 0;
    		rep(i, 0, n - 1) {
    			res += s[i] - '0' - 1;
    			ans += st[res]++;
    		}
    		cout << ans << '
    ';
    	}
    	return 0;
    }
    

    D

    dp

    #include <bits/stdc++.h>
    #define all(n) (n).begin(), (n).end()
    #define se second
    #define fi first
    #define pb push_back
    #define mp make_pair
    #define sqr(n) (n)*(n)
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define IO ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
    using namespace std;
    typedef long long ll;
    typedef pair<int, int> PII;
    typedef pair<ll, ll> PLL;
    typedef vector<int> VI;
    typedef double db;
    
    const int N = 200 + 5;
    
    int n, m, _, k;
    int a[N], b[N], c[N];
    ll f[N][N][N];
    
    int main() {
        IO; cin >> n >> m >> k;
    	rep (i, 1, n) cin >> a[i];
    	sort(a + 1, a + n + 1);
    	rep (i, 1, m) cin >> b[i];
    	sort(b + 1, b + 1 + m);
    	rep (i, 1, k) cin >> c[i];
    	sort(c + 1, c + 1 + k);
     
    	per (i, n, 0)
    		per (j, m, 0)
    			per (h, k, 0) {
    				if (i && j)
    					f[i - 1][j - 1][h] = max(f[i - 1][j - 1][h], f[i][j][h] + a[i] * b[j]);
    				if (i && h)
    					f[i - 1][j][h - 1] = max(f[i - 1][j][h - 1], f[i][j][h] + a[i] * c[h]);
    				if (j && h)
    					f[i][j - 1][h - 1] = max(f[i][j - 1][h - 1], f[i][j][h] + b[j] * c[h]);
    			}
    
    	ll ans = 0;
    	rep (i, 0, n)
    		rep (j, 0, m)
    			rep (h, 0, k)
    				ans = max(ans, f[i][j][h]);
    
    	cout << ans;
        return 0;
    }
    
  • 相关阅读:
    C# 如何定义让PropertyGrid控件显示[...]按钮,并且点击后以下拉框形式显示自定义控件编辑属性值
    “Word自动更改后的内容保存到通用文档模板上。是否加载该模板?“的解决办法
    Web服务器之iis,apache,tomcat三者之间的比较
    [转]C#如何把文件夹压缩打包然后下载
    [转]C#压缩打包文件
    C#——Marshal.StructureToPtr方法简介
    [Android Pro] 内容提供者ContentProvider的基本使用
    [Linux] awk命令详解
    [Linux] AWK命令详解(大全)
    [Android UI] ProgressBar自定义
  • 原文地址:https://www.cnblogs.com/2aptx4869/p/13526832.html
Copyright © 2020-2023  润新知