Submission #530731

#TimeUsernameProblemLanguageResultExecution timeMemory
530731Killer2501Cover (COCI18_cover)C++14
120 / 120
3 ms864 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 5e3+5; const int M = 250; const int mod = 1e9+7; const ll base = 75; const int inf = 1e9; int n, t, b[N][N], d[N], lab[N], c[N], a[N][N]; ll ans, tong, dp[N]; ll m, k; pii p[N], start, finish; vector<int> gx[N], gy[N]; vector<pii> vi; string s[N]; void sol() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> p[i].fi >> p[i].se; p[i].fi = abs(p[i].fi); p[i].se = abs(p[i].se); } sort(p+1, p+1+n); for(int i = 1; i <= n; i ++) { while(!vi.empty() && vi.back().se <= p[i].se)vi.pop_back(); vi.pb(p[i]); } for(int i = 1; i <= vi.size(); i ++) { dp[i] = 1ll * vi[0].se * vi[i-1].fi; for(int j = 1; j <= i; j ++) { dp[i] = min(dp[i], dp[j-1] + 1ll*vi[j-1].se * vi[i-1].fi); } } cout << dp[vi.size()]*4; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; }

Compilation message (stderr)

cover.cpp: In function 'void sol()':
cover.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i = 1; i <= vi.size(); i ++)
      |                    ~~^~~~~~~~~~~~
cover.cpp: In function 'int main()':
cover.cpp:56:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cover.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...