제출 #1103715

#제출 시각아이디문제언어결과실행 시간메모리
1103715khoile25108Cloud Computing (CEOI18_clo)C++14
100 / 100
770 ms2296 KiB
#include <bits/stdc++.h> using namespace std; #define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define FOR(i,a,b) for(int i = a; i <= b; i++) #define FOD(i,a,b) for(int i = a; i >= b; i--) #define int long long #define fi first #define se second #define pb push_back #define ll long long #define ull unsigned long long #define lcm(a,b) (a*b)/__gcd(a,b) #define ii pair<int,int> #define iii pair<int,pair<int,int>> #define iv pair<pair<int,int>,pair<int,int>> const int inf = 1e9; const ll INF = 1e18; const int mod = 1e9 + 7; const int N = 1e5 + 105; const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1}; const int dxx[] = {-1,-1,0,1,1,1,0,-1}; const int dyy[] = {0,1,1,1,0,-1,-1,-1}; struct dat { int c, f, v; }; bool cmp(dat a, dat b) { return a.f != b.f ? a.f > b.f : a.v < b.v; } int n, sum, m; vector<dat> a; int dp[N][2]; void solve() { sort(a.begin(), a.end(), cmp); FOR(i,1,sum) dp[i][0] = -INF; for(int i = 0; i < a.size(); i++) { for(int j = 0; j <= sum; j++) dp[j][1] = dp[j][0]; for(int j = 0; j <= sum; j++) { int pre = j - a[i].c; if(pre >= 0 && pre <= sum && dp[pre][0] != -INF) dp[j][1] = max(dp[j][1], dp[pre][0] + a[i].v); } for(int j = 0; j <= sum; j++) dp[j][0] = dp[j][1]; } int ans = -INF; FOR(i,0,sum) ans = max(ans, dp[i][0]); cout << ans; } void input() { //freopen("TEST.INP", "r", stdin); //freopen("TEST.OUT", "w", stdout); cin >> n; FOR(i,1,n) { int c, f, v; cin >> c >> f >> v; a.pb({c,f,-v}); sum += c; } cin >> m; FOR(i,1,m) { int c, f, v; cin >> c >> f >> v; a.pb({-c,f,v}); } } signed main() { faster input(); solve(); }

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

clo.cpp: In function 'void solve()':
clo.cpp:46:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<dat>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < a.size(); i++)
      |                    ~~^~~~~~~~~~
#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...