結果

問題 No.1077 Noelちゃんと星々4
ユーザー At-sushiAt-sushi
提出日時 2020-06-12 21:49:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,583 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 120,576 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-06 10:12:51
合計ジャッジ時間 1,955 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//
//  main.cpp
//  AtCoder
//
//  Created by atsushi on 2019/12/29.
//

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <bitset>

#define REP(i, N) for(int i=0; i<(N); i++)
#define ALL(N) (N).begin(), (N).end()
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;

using ll = long long;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N;
  invec<ll> I(N);

  ll r = 0;
  
  for (int i = N - 1; i >= 1; i--) {
    if (I[i-1] > I[i]) {
      r += I[i-1] - I[i];
    }
  }
  
  return r;
}


template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main(int argc, const char * argv[]) {
    // insert code here...
    plot(solve);
    return 0;
}
0