제출 #362195

#제출 시각아이디문제언어결과실행 시간메모리
362195sumit_kk10Cloud Computing (CEOI18_clo)C++14
100 / 100
1138 ms2284 KiB
#include<bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define ll long long int using namespace std; const int MOD = 1e9 + 7; const int N = 2e5 + 5; long long int dp[1000000 + 1], sum = 0; vector<pair<long long int, pair<long long int, long long int> > > v; void solve() { int n; cin >> n; for(int i = 0; i < n; ++i){ long long int c, f, p; cin >> c >> f >> p; sum += c; p *= -1; v.push_back({f, {c, p}}); } int m; cin >> m; for(int i = 0; i < m; ++i){ long long int c, f, p; cin >> c >> f >> p; sum += c; c *= -1; v.push_back({f, {c, p}}); } sort(v.begin(), v.end()); for(int i = 0; i < v.size(); ++i){ int f = v[i].first, c = v[i].second.first, p = v[i].second.second; if(p < 0){ // buying a computer; for(int cores = 0; cores <= sum; ++cores) if(cores + c >= 0 and cores + c <= sum) // if i have this many cores already; dp[cores] = max(dp[cores], dp[cores + c] + p); } else{ // taking an order; for(int cores = sum; cores >= 0; --cores) // if i have this many cores already; if(cores + c >= 0 and cores + c <= sum) // I can take this order then. dp[cores] = max(dp[cores], dp[cores + c] + p); } } cout << dp[0] << "\n"; } int main() { fast; int t = 1; // cin >> t; while(t--) solve(); return 0; }

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

clo.cpp: In function 'void solve()':
clo.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0; i < v.size(); ++i){
      |                    ~~^~~~~~~~~~
clo.cpp:31:13: warning: unused variable 'f' [-Wunused-variable]
   31 |         int f = v[i].first, c = v[i].second.first, p = v[i].second.second;
      |             ^
#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...