結果

問題 No.789 範囲の合計
ユーザー 👑 emthrmemthrm
提出日時 2019-02-08 22:29:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,356 bytes
コンパイル時間 1,213 ms
コンパイル使用メモリ 126,660 KB
実行使用メモリ 8,816 KB
最終ジャッジ日時 2023-09-14 03:49:24
合計ジャッジ時間 3,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<bool> docchi(n, false); // true -> query
  vector<pair<int, int>> ar, query;
  REP(i, n) {
    int q, x, y; cin >> q >> x >> y;
    if (q == 0) ar.push_back({x, y});
    else {
      docchi[i] = true;
      query.push_back({x, y});
    }
  }
  int a = 0, q = 0, sz = query.size();
  long long ans = 0;
  REP(i, n) {
    if (docchi[i] == 0) {
      FOR(j, q, sz) {
        if (query[j].first <= ar[a].first && ar[a].first <= query[j].second) ans += ar[a].second;
      }
      ++a;
    } else ++q;
  }
  cout << ans << '\n';
  return 0;
}
0