Submission #1108873

#TimeUsernameProblemLanguageResultExecution timeMemory
1108873hainam2k9Stove (JOI18_stove)C++17
0 / 100
1 ms592 KiB
#include <bits/stdc++.h> #define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0) #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout) #define ll long long #define ull unsigned long long #define i128 __int128 #define db long double #define sz(a) ((int)(a).size()) #define pb emplace_back #define pf emplace_front #define pob pop_back #define pof pop_front #define lb lower_bound #define ub upper_bound #define fi first #define se second #define ins emplace using namespace std; const int MOD = 1e9+7, MAXN = 1e5+5; const string NAME = ""; int n,k,a[MAXN]; int bs(int l, int r){ int rs=r; while(l<=r){ int mid=(l+r)>>1,cnt=0,pre=a[1],sum=0; for(int i = 1; i<n; ++i) if(a[i+1]+1-pre>mid) ++cnt, sum+=a[i]+1-pre, pre=a[i+1]; sum+=a[n]+1-pre; if(cnt+1<=k) rs=sum, r=mid-1; else l=mid+1; } return rs; } int main() { tt; if(fopen((NAME + ".INP").c_str(), "r")) fo; cin >> n >> k; for(int i = 1; i<=n; ++i) cin >> a[i]; cout << bs(1,2e9); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:3:19: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:37:45: note: in expansion of macro 'fo'
   37 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
stove.cpp:3:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    3 | #define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
      |                                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:37:45: note: in expansion of macro 'fo'
   37 |     if(fopen((NAME + ".INP").c_str(), "r")) fo;
      |                                             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...