답안 #978303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978303 2024-05-09T06:00:04 Z mannshah1211 Fish 3 (JOI24_fish3) C++17
0 / 100
71 ms 10560 KB
/**
 *  author: hashman
 *  created:
**/

#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() {
  cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

using Int = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  Int d;
  cin >> d;
  vector<Int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  vector<Int> difs(n - 1);
  for (int i = 0; i < n - 1; i++) {
    difs[i] = max(c[i] - c[i + 1], Int(0));
    if (i > 0) {
      difs[i] += difs[i - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    --l; --r;
    Int ans = 0;
    if (r > 0) {
      ans += difs[r - 1];
    }
    if (l > 0) {
      ans -= difs[l - 1];
    }
    if (0) {
      cout << -1 << '\n';
    } else {
      cout << ans << '\n';
    }
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 10560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 7400 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 6996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -