제출 #754615

#제출 시각아이디문제언어결과실행 시간메모리
754615RafatStove (JOI18_stove)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> p32; typedef pair<ll,ll> p64; typedef pair<double,double> pdd; typedef vector<ll> v64; typedef vector<int> v32; typedef vector<vector<int> > vv32; typedef vector<vector<ll> > vv64; typedef vector<vector<p64> > vvp64; typedef vector<p64> vp64; typedef vector<p32> vp32; typedef vector<bool> vb; ll mod = 1e9 + 7; double eps = 1e-12; // #define forn(i,e) for(ll i = 0; i < e; i++) #define FOR(s, e, i) for(ll i = s; i <= e; i++) // #define rforn(i,s) for(ll i = s; i >= 0; i--) #define ROF(s ,e, i) for(ll i = s; i >= e; i--) #define ln "\n" #define dbg(x) cout<<#x<<" = "<<x<<ln #define mp make_pair #define mt make_tuple #define pb push_back #define fi first #define se second #define INF 2e18 #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define yes cout<<"Yes\n" #define no cout<<"No\n" using namespace std; int main() { ll n, k; cin >> n >> k; v64 A(n); for(ll &x : A) cin >> x; v64 B; if(n == 1){ cout << 1; return; } if(k >= n){ cout << n; return; } FOR(1, n - 1, i) { B.pb(A[i] - A[i - 1] - 1); } sort(rall(B)); ll j = min((ll)B.size(), k - 1), ans = 0; for(ll i = 0; i < B.size(); i++) { if(k == 1) break; ans += B[i]; k--; } cout << A[n - 1] - ans ; return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:50:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   50 |         return;
      |         ^~~~~~
stove.cpp:54:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   54 |         return;
      |         ^~~~~~
stove.cpp:63:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(ll i = 0; i < B.size(); i++)
      |                   ~~^~~~~~~~~~
stove.cpp:61:9: warning: unused variable 'j' [-Wunused-variable]
   61 |     ll  j = min((ll)B.size(), k - 1), ans = 0;
      |         ^