답안 #306315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306315 2020-09-25T08:02:14 Z baibhav26062008 Stove (JOI18_stove) C++14
0 / 100
0 ms 256 KB
#include <iostream>
#include <vector>
#include <algorithm>

#define int long long

signed main() {
  int n , k;
  std::cin >> n >> k;
  std::vector <int> a(n) , d(n);
  
  for (int i = 0;i < n;i++) {
    std::cin >> a[i];
  }
  
  std::sort(a.begin(),a.end()); 
  for (int i = 1;i < d.size();i++) {
    d[i] = a[i] - a[i-1];
  }  
  
  int ans = 0;
  for (int i = 0;i < d.size();i++) {
    ans += d[i];
  }	
  
  std::cout << ans - 1 << std::endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:17:20: 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]
   17 |   for (int i = 1;i < d.size();i++) {
      |                  ~~^~~~~~~~~~
stove.cpp:22:20: 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]
   22 |   for (int i = 0;i < d.size();i++) {
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -