제출 #484187

#제출 시각아이디문제언어결과실행 시간메모리
484187Killer2501Cloud Computing (CEOI18_clo)C++14
18 / 100
3 ms844 KiB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
using namespace std;
const int N = 2e3+15;
const int M = 550;
const ll mod = 998244353;
const ld base = 1e6;
const ll inf = 1e16;
const ld pi = acos(-1);
ll n, m, k, ans,  cnt[N], t, dp[N], c[N], tong, lab[N], a[N], b[N];
vector<ll> adj[N];
string s[N];
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
vector<ll> kq;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n&1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
ll findp(ll u)
{
    return lab[u] < 0 ? u : lab[u] = findp(lab[u]);
}
void hop(ll u, ll v)
{
    if(lab[u] > lab[v])swap(u, v);
    lab[u] += lab[v];
    lab[v] = u;
    k = max(k, -lab[u]);
}
struct BIT
{
    ll n;
    vector<ll> fe;
    BIT(ll _n)
    {
        n = _n;
        fe.resize(n+1, 0);
    }
    void add(ll id, ll x)
    {
        for(; id <= n; id += id & -id)fe[id] = max(fe[id], x);
    }
    ll get(ll id)
    {
        ll total = 0;
        for(; id; id -= id & -id)total = max(total, fe[id]);
        return total;
    }
};
struct node
{
    ll f, c, v, ok;
    bool operator < (const node& x)
    {
        return (f > x.f) || (f == x.f && ok > x.ok);
    }
}st[N*2];
void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> st[i].c >> st[i].f >> st[i].v;
        st[i].ok = 1;
    }
    cin >> m;
    for(int i = 1; i <= m; i ++)
    {
        cin >> st[i+n].c >> st[i+n].f >> st[i+n].v;
        st[i+n].ok = 0;
    }
    sort(st+1, st+1+m+n);
    fill_n(dp, n*50+1, -inf);
    dp[0] = 0;
    for(int i = 1; i <= n+m; i ++)
    {
        //cout << st[i].ok <<" "<<st[i].c<<" "<<st[i].f <<" "<<st[i].v << '\n';
        if(st[i].ok)
        {
            k += st[i].c;
            for(int j = k; j > 0; j --)if(dp[max(0ll, j-st[i].c)] != -inf)dp[j] = max(dp[j], dp[max(0ll, j-st[i].c)]-st[i].v);
        }
        else
        {
            for(int j = 0; j <= k-st[i].c; j ++)if(dp[j+st[i].c] != -inf)dp[j] = max(dp[j], dp[j+st[i].c]+st[i].v);
        }
        //for(int j = 0; j <= k; j ++)cout << dp[j] <<" ";
        //cout << '\n';
    }
    for(int i = 0; i <= k; i ++)ans = max(ans, dp[i]);
    cout << ans;
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    #define task "tests"
    if(fopen(task".inp", "r"))
	{
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}
    int test = 1;
    //cin >> test;
    while(test -- > 0)sol();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'int main()':
clo.cpp:114:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  114 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:115:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  115 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...