답안 #365991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
365991 2021-02-12T16:28:27 Z vishesh312 Stove (JOI18_stove) C++17
50 / 100
1000 ms 5476 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
void solve(){
    int number = 0;
    cerr << number << '\n'; ++number;
  int tc,k;
  cin>>tc>>k;
  k--;
  vector<int>v,diff;
  for(int i=0;i<tc;i++){
    int n;
    cin>>n;
    v.push_back(n);
    v.push_back(n+1);
  }
    cerr << number << '\n'; ++number;
  int ans=0;
  ans+=tc;
    cerr << number << '\n'; ++number;
  auto st = v.begin();
  auto end = v.end();
  end--;
  v.erase(end);
  v.erase(st);
    cerr << number << '\n'; ++number;
  for(int i=0;i<v.size();i+=2){
    diff.push_back(v[i+1]-v[i]);
  }
    cerr << number << '\n'; ++number;
  sort(diff.rbegin(),diff.rend());
    cerr << number << '\n'; ++number;
  while(k!=0){
    cerr << number << '\n'; ++number;
    auto it = diff.begin();
    diff.erase(it);
    k--;
  }
    cerr << number << '\n'; ++number;
  for(int i=0;i<diff.size();i++){
    ans+=diff[i];
    cerr << number << '\n'; ++number;
  }
    cerr << number << '\n'; ++number;
  cout<<ans;
}
signed main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int tc=1;
  for(int i=0;i<tc;i++)solve();
  return 0;
}

Compilation message

stove.cpp: In function 'void solve()':
stove.cpp:28:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for(int i=0;i<v.size();i+=2){
      |               ~^~~~~~~~~
stove.cpp:41:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   for(int i=0;i<diff.size();i++){
      |               ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 14 ms 492 KB Output is correct
11 Correct 15 ms 492 KB Output is correct
12 Correct 15 ms 492 KB Output is correct
13 Correct 17 ms 492 KB Output is correct
14 Correct 16 ms 492 KB Output is correct
15 Correct 16 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 14 ms 492 KB Output is correct
11 Correct 15 ms 492 KB Output is correct
12 Correct 15 ms 492 KB Output is correct
13 Correct 17 ms 492 KB Output is correct
14 Correct 16 ms 492 KB Output is correct
15 Correct 16 ms 492 KB Output is correct
16 Correct 454 ms 5348 KB Output is correct
17 Correct 461 ms 5348 KB Output is correct
18 Correct 523 ms 5220 KB Output is correct
19 Execution timed out 1091 ms 5476 KB Time limit exceeded
20 Halted 0 ms 0 KB -