Submission #1110266

#TimeUsernameProblemLanguageResultExecution timeMemory
1110266vjudge1Tower (JOI24_tower)C++17
5 / 100
59 ms18628 KiB
#include <bits/stdc++.h> #define Y8o "Tower" #define maxn (int) 2e5 + 5 #define ll long long #define pii pair<int, int> #define gb(i, j) ((i >> j) & 1) #define all(x) x.begin(), x.end() #define _left id * 2, l, mid #define _right id * 2 + 1, mid + 1, r #define fi(i, a, b) for(int i = a; i <= b; i ++) #define fid(i, a, b) for(int i = a; i >= b; i --) #define f first #define s second using namespace std; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll GetRandom(ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rng); } void iof() { ios_base::sync_with_stdio(0); cin.tie(NULL), cout.tie(NULL); if(fopen(Y8o".inp", "r")) { freopen(Y8o".inp", "r", stdin); // freopen(Y8o".out", "w", stdout); } } void ctime() { cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; } const ll INF = 1e18; const int maxn_val = 1e6; int n, Q, A, B; ll D; pair<ll, ll> a[maxn]; ll qr[maxn], mx; namespace sub1 { ll dp[maxn_val + 5]; int dem[maxn_val + 5]; void solve() { fi(i, 1, n) { dem[a[i].f] ++, dem[a[i].s + 1] --; } fi(i, 0, maxn_val) dem[i] += dem[i - 1]; fi(i, 1, maxn_val) dp[i] = INF; fi(i, 1, maxn_val) if(!dem[i]) { if(!dem[i - 1]) dp[i] = min(dp[i], dp[i - 1] + A); if(i >= D && !dem[i - D]) dp[i] = min(dp[i], dp[i - D] + B); } fi(i, 1, Q) { if(dp[qr[i]] == INF) cout << -1 << '\n'; else cout << dp[qr[i]] << '\n'; } } } void solve() { cin >> n >> Q; cin >> D >> A >> B; fi(i, 1, n) cin >> a[i].f >> a[i].s, mx = max(mx, a[i].s); fi(i, 1, Q) cin >> qr[i], mx = max(mx, qr[i]); assert(mx <= 1e6); sub1::solve(); } int main() { iof(); int nTest = 1; // cin >> nTest; while(nTest --) { solve(); } ctime(); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void iof()':
Main.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         freopen(Y8o".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...