Submission #1110227

#TimeUsernameProblemLanguageResultExecution timeMemory
1110227vjudge1Tower (JOI24_tower)C++17
5 / 100
63 ms20552 KiB
#include<bits/stdc++.h> using namespace std; int n,q; long long d,a,b; long long f[2000000]; int k[2000000]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("c.INP","r")){ freopen("c.INP","r",stdin); freopen("c.OUT","w",stdout); } cin >>n>>q; cin >>d>>a>>b; while(n--){ int l,r; cin >>l>>r; k[l]++; k[r+1]--; } for(int i=1;i<=1000000;i++){ k[i]+=k[i-1]; if(k[i])f[i]=1e17; else{ if(i>=d)f[i]=min(f[i-1]+a,f[i-d]+b); else f[i]=f[i-1]+a; } } while(q--){ int x; cin >>x; if(f[x]<1e17)cout <<f[x]<<'\n'; else cout <<-1<<'\n'; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:12:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         freopen("c.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         freopen("c.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...