제출 #1266690

#제출 시각아이디문제언어결과실행 시간메모리
1266690nonjapenzilStove (JOI18_stove)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pf(a) printf("%.9f", a) #define SZ size() #define ll long long #define pb push_back #define BBC ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); void W2dNHK() { ll n,k; cin>>n>>k; ll a[n+2]; ll i; ll dih=0; ll m=1e18,n=0; ll z[n+11]; for(i=1 ; i<=n ; i++ ){ cin>>a[i]; m=min(m,a[i]); n=max(n,a[i]); } dih=n-m+1; ll g=0; for(i=1 ; i<n ; i++ ){ z[i]=a[i+1]-a[i]-1; } sort(z+1,z+n); for(i=n-1 ; i>=1 ;i--){ dih-=z[i]; g++; if(g==k){ break; } } cout<<dih; } int main() { BBC ll tc = 1; //cin >> tc; while (tc--) { W2dNHK(); } }

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

stove.cpp: In function 'void W2dNHK()':
stove.cpp:14:15: error: redeclaration of 'long long int n'
   14 |     ll m=1e18,n=0;
      |               ^
stove.cpp:9:8: note: 'long long int n' previously declared here
    9 |     ll n,k;
      |        ^