제출 #572609

#제출 시각아이디문제언어결과실행 시간메모리
572609MohammadAghilStove (JOI18_stove)C++17
100 / 100
26 ms1376 KiB
#include <bits/stdc++.h> // #pragma GCC optimize ("Ofast,unroll-loops") // #pragma GCC target ("avx2") using namespace std; typedef long long ll; typedef pair<int, int> pp; #define er(args ...) cerr << __LINE__ << ": ", err(new istringstream(string(#args)), args), cerr << endl #define per(i,r,l) for(int i = (r); i >= (l); i--) #define rep(i,l,r) for(int i = (l); i < (r); i++) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define pb push_back #define ss second #define ff first void err(istringstream *iss){}template<typename T,typename ...Args> void err(istringstream *iss,const T &_val, const Args&...args){string _name;*iss>>_name;if(_name.back()==',')_name.pop_back();cerr<<_name<<" = "<<_val<<", ",err(iss,args...);} mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const ll mod = 1e9 + 7, maxn = 5e5 + 5, lg = 22, lng = 26, inf = ll(1e9) + 5; ll pw(ll a,ll b,ll md=mod){if(!b)return 1;ll k=pw(a,b>>1ll);return k*k%md*(b&1ll?a:1)%md;} int main(){ cin.tie(0) -> sync_with_stdio(0); int n, k; cin >> n >> k; k--; vector<int> t(n); rep(i,0,n) cin >> t[i]; sort(all(t)); ll ans = t.back() - t[0] + 1; vector<int> space; rep(i,1,n) space.pb(t[i]-t[i-1]-1); sort(all(space)); while(k-- && sz(space)) ans -= space.back(), space.pop_back(); cout << ans << '\n'; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp: In function 'int main()':
stove.cpp:9:28: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    9 |         #define rep(i,l,r) for(int i = (l); i < (r); i++)
      |                            ^~~
stove.cpp:24:6: note: in expansion of macro 'rep'
   24 |      rep(i,0,n) cin >> t[i]; sort(all(t));
      |      ^~~
stove.cpp:24:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |      rep(i,0,n) cin >> t[i]; sort(all(t));
      |                              ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...