Submission #868903

# Submission time Handle Problem Language Result Execution time Memory
868903 2023-11-02T12:15:14 Z autoastt Stove (JOI18_stove) C++14
0 / 100
0 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int a[N], b[N], ans, cnt;

int main(){
 int n, k;
  cin >> n >> k;
  vector<pair<int,pair<int,int>>> v;
  for(int i=0;i<n;i++){
cin >> a[i];
    if(i>0) v.push_back({a[i]-a[i-1]+1,{i,i-1}});
}
  sort(v.begin(),v.end());
  for(int i=0,j=0;i<v.size();i++){
ans+=v[i].first;
    j++;
    if(!b[v[i].second.first]) b[v[i].second.first]=1,cnt++;
      if(!b[v[i].second.second]) b[v[i].second.second] = 1,cnt++;
    if(n-cnt+j==k){
cout << ans+j;
}
}

}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int i=0,j=0;i<v.size();i++){
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -