Submission #694025

#TimeUsernameProblemLanguageResultExecution timeMemory
6940254EVERSightseeing in Kyoto (JOI22_kyoto)C++11
10 / 100
10 ms8364 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define PB push_back #define ALL(i_) i_.begin(), i_.end() #define LOG2(x_) (31 - __builtin_clz(x_)) #define getBit(x_, i_) ((x_ >> i_) & (ll) 1) #define rd(l_, r_) (l_ + rng() % (r_ - l_ + 1)) #define FOR(i_, a_, b_) for(int i_ = (int) (a_); i_ <= (int) (b_); ++i_) #define FORD(i_, a_, b_) for(int i_ = (int) (a_); i_ >= (int) (b_); --i_) void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;} void __print(float x) {cerr << x;} void __print(double x) {cerr << x;} void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';} void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';} void __print(bool x) {cerr << (x ? "true" : "false");} template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';} template<typename T> void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";} template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);} #ifndef DEBUG #define debug(x...) cerr << "[" << #x << "] = ["; _print(x) #else #define debug(x...) #endif typedef long long ll; typedef long double ld; template<class X, class Y> bool minimize(X &x, const Y &y){ X eps = 1e-9; if (x > y + eps) { x = y; return 1; } return 0; } template<class X, class Y> bool maximize(X &x, const Y &y) { X eps = 1e-9; if (x + eps < y) { x = y; return 1; } return 0; } template<class T> T Abs(const T &x) { return (x < 0 ? -x : x); } template<class T> using heap_min = priority_queue<T, vector<T>, greater<T>>; template<class T> using heap_max = priority_queue<T>; // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; // typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> OST; const int mod = (int) 1e9 + 7; // 998244353 const int oo = (int) 1e9 + 99; const array<int, 2> dxy8[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1}, {1, -1}, {1, 1}, {-1, 1}, {-1, -1} }; const array<int, 2> dxy4[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} }; const int maxn = (int) 1e3 + 11; const int LOG = (int) LOG2(maxn) + 3; void File(){ #define TASK "KYOTO" if(fopen(TASK".inp", "r")) { freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } } int n, m; int a[maxn], b[maxn]; void ReadInput(){ cin >> n >> m; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, m) cin >> b[i]; } ll dp[maxn][maxn]; void Solve(){ memset(dp, 0x3f, sizeof dp); dp[1][1] = 0; FOR(i, 1, n) FOR(j, 1, m){ if(i - 1 >= 1) minimize(dp[i][j], dp[i - 1][j] + (ll) b[j]); if(j - 1 >= 1) minimize(dp[i][j], dp[i][j - 1] + (ll) a[i]); } cout << dp[n][m]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); File(); ReadInput(); Solve(); cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n"; return 0; }

Compilation message (stderr)

kyoto.cpp: In function 'void File()':
kyoto.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
kyoto.cpp:83:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...