제출 #1292581

#제출 시각아이디문제언어결과실행 시간메모리
1292581maxphastCloud Computing (CEOI18_clo)C++20
100 / 100
219 ms1340 KiB
/* * @Author: MaxPhast * @File: test.cpp * @Date: 2025-11-19 21:45:30 */ #include <bits/stdc++.h> using namespace std; #define int long long #define ii pair <int , int> #define iii pair <int , ii> #define iiii pair <ii , ii> #define FOR(i , l , r) for(int i = (l) , _r = (r) ; i <= _r ; ++ i) #define FORD(i , r , l) for(int i = (r) , _l = (l) ; i >= _l ; -- i) #define ALL(vec) vec.begin() , vec.end() #define UNI(vec) sort(ALL(vec)) , vec.erase(unique(ALL(vec)) , vec.end()) #define pb push_back #define MASK(i) (1ll << i) #define BIT(mask , i) ((mask >> i) & 1ll) #define ON(mask , i) (mask | MASK(i)) #define OFF(mask , i) (mask & (~MASK(i))) #define TURN(mask , i) (mask ^ MASK(i)) #define BP(mask) __builtin_popcountll(mask) #define sqr(x) (1ll * (x) * (x)) #define fi first #define se second #define oo 1e18 #define time() cerr << " \n " << "Time : " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms." #define IO(TASK) if(fopen(#TASK".INP" , "r")){freopen(#TASK".INP" , "r" , stdin); freopen(#TASK".OUT" , "w" , stdout);} template <class X , class Y> bool maxz(X &a , const Y b) { if(a < b) { a = b; return true; } return false; } template <class X , class Y> bool minz(X &a , const Y b) { if(a > b) { a = b; return true; } return false; } namespace MaxPhast { const int N = 4e3 + 5; const int S = 1e5 + 5; int n , m , s; int dp[S]; struct Data { int c , f , v; bool op; Data() { c = f = v = 0; op = false; } bool operator < (const Data &other) const { if(f != other.f) return f > other.f; else return op > other.op; } }a[N]; void solve() { cin >> n; FOR(i , 1 , n) { cin >> a[i].c >> a[i].f >> a[i].v; a[i].op = true; s += a[i].c; } cin >> m; FOR(i , n + 1 , n + m) { cin >> a[i].c >> a[i].f >> a[i].v; a[i].op = false; } sort(a + 1 , a + n + m + 1); FOR(i , 0 , s) dp[i] = -oo; dp[0] = 0; s = 0; FOR(i , 1 , n + m) { if(a[i].op) { FORD(j , s , 0) { maxz(dp[j + a[i].c] , dp[j] - a[i].v); } s += a[i].c; } else { FOR(j , a[i].c , s) { maxz(dp[j - a[i].c] , dp[j] + a[i].v); } } } cout << *max_element(dp , dp + s + 1); } } signed main() { ios_base :: sync_with_stdio(false) ; cin.tie(nullptr) ; cout.tie(nullptr) ; IO(test); MaxPhast :: solve(); time(); } /* */

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

clo.cpp: In function 'int main()':
clo.cpp:29:54: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 | #define IO(TASK) if(fopen(#TASK".INP" , "r")){freopen(#TASK".INP" , "r" , stdin); freopen(#TASK".OUT" , "w" , stdout);}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:131:5: note: in expansion of macro 'IO'
  131 |     IO(test);
      |     ^~
clo.cpp:29:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 | #define IO(TASK) if(fopen(#TASK".INP" , "r")){freopen(#TASK".INP" , "r" , stdin); freopen(#TASK".OUT" , "w" , stdout);}
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:131:5: note: in expansion of macro 'IO'
  131 |     IO(test);
      |     ^~
#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...