제출 #810693

#제출 시각아이디문제언어결과실행 시간메모리
810693thefless코알라 (JOI13_koala)C++14
20 / 100
2045 ms6708 KiB
#include<bits/stdc++.h> using namespace std; #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1) #define Times (1.0 * clock() / CLOCKS_PER_SEC) #define fi first #define base 31 #define sz(x) (int)(x).size() #define se second #define ll long long #define mp make_pair #define pb push_back #define pii pair<int, int> #define all(x) (x).begin(), (x).end() #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); } #define task "name" #define tsk "" const int oo = 1e9 + 7; const ll loo = (ll)1e18 + 7; const int MOD = 1e9 + 7; const int MOD2 = 1e9 + 696969; const int N = 2e5 + 3; const int BASE = 10; template <typename T1, typename T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;} return false;} template <typename T1, typename T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;} return false;} ll n , m , k , d , a , t[N] , b[N] , pre[N] , dp[N] , p[N]; ll st[N << 2]; vector<int> nen; void update(int id , int l , int r , int i , int val){ if(l == r) return void(st[id] = val); int mid = l + r >> 1; if(i <= mid) update(id << 1 , l , mid , i , val); if(mid + 1 <= i) update(id << 1 | 1 , mid + 1 , r , i , val); st[id] = max(st[id << 1] , st[id << 1 | 1]); } ll get(int id , int l , int r , int u , int v){ if(l > v || r < u) return -oo; if(u <= l && r <= v) return st[id]; int mid = l + r >> 1; return max(get(id << 1 , l , mid , u , v) , get(id << 1 | 1 , mid + 1 , r , u , v)); } void Solve(){ cin >> k >> m >> d >> a >> n; t[0] = k; p[0] = k % d; t[n + 1] = m; p[n + 1] = m % d; memset(dp , -0x3f , sizeof dp); dp[0] = 0; for(int i = 1 ; i <= n ; i++){ cin >> t[i] >> b[i]; p[i] = t[i] % d; nen.pb(t[i]); } for(int i = 1 ; i <= n + 1 ; i++){ for(int j = 0 ; j < i ; j++){ maximize(dp[i] , dp[j] - (t[i] / d - t[j] / d + (p[i] > p[j])) * a + b[i]); } } cout << dp[n + 1]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); file(task); file(tsk); int T = 1; // cin >> T; while(T--) { Solve(); } cerr << "Time elapsed: " << Times << " s.\n"; return 0; }

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

koala.cpp: In function 'void update(int, int, int, int, int)':
koala.cpp:36:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   36 |  int mid = l + r >> 1;
      |            ~~^~~
koala.cpp: In function 'long long int get(int, int, int, int, int)':
koala.cpp:45:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |  int mid = l + r >> 1;
      |            ~~^~~
koala.cpp: In function 'int main()':
koala.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:73:5: note: in expansion of macro 'file'
   73 |     file(task);
      |     ^~~~
koala.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:73:5: note: in expansion of macro 'file'
   73 |     file(task);
      |     ^~~~
koala.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:73:5: note: in expansion of macro 'file'
   73 |     file(task);
      |     ^~~~
koala.cpp:16:58: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:74:5: note: in expansion of macro 'file'
   74 |     file(tsk);
      |     ^~~~
koala.cpp:16:91: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:74:5: note: in expansion of macro 'file'
   74 |     file(tsk);
      |     ^~~~
koala.cpp:16:125: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); freopen(name".bug", "w", stderr); }
      |                                                                                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
koala.cpp:74:5: note: in expansion of macro 'file'
   74 |     file(tsk);
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...