제출 #1256655

#제출 시각아이디문제언어결과실행 시간메모리
1256655nicecoder37Stove (JOI18_stove)C++20
100 / 100
24 ms5844 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL) #define fi first #define se second #define space " " #define endl "\n" #define gcd __gcd #define mp make_pair #define pb push_back #define pf push_front #define lb lower_bound #define ub upper_bound #define md 1000000007 #define inf 1000000000 #define li 500005 #define int long long using namespace std; int T,Q,n,m,a[li],l[li],r[li]; string s,t; priority_queue<pair<int,pair<int,int> > > pq; int32_t main(){ scanf("%lld %lld",&n,&m); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); l[i]=a[i]; r[i]=a[i]+1; } for(int i=1;i<n;i++){ pq.push(mp(-(a[i+1]-(a[i]+1)),mp(i,i+1))); } int sayi=n-m; while(sayi--){ pair<int,pair<int,int> > temp=pq.top(); pq.pop(); int ind1=temp.se.fi; int ind2=temp.se.se; r[ind1]=r[ind2]; } int cev=0; for(int i=1;i<=n;i++){ int son=i+1; while(son<=n && r[son-1]>=l[son]) son++; son--; cev+=r[son]-l[i]; i=son; } printf("%lld\n",cev); return 0; }

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

stove.cpp: In function 'int32_t main()':
stove.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%lld %lld",&n,&m);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
stove.cpp:26:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |                 scanf("%lld",&a[i]);
      |                 ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...