結果

問題 No.2462 七人カノン
ユーザー 👑 NachiaNachia
提出日時 2021-05-30 12:48:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 1,539 bytes
コンパイル時間 6,245 ms
コンパイル使用メモリ 222,900 KB
実行使用メモリ 8,564 KB
最終ジャッジ日時 2023-09-08 20:50:29
合計ジャッジ時間 12,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 101 ms
7,256 KB
testcase_14 AC 110 ms
7,464 KB
testcase_15 AC 103 ms
7,412 KB
testcase_16 AC 117 ms
7,712 KB
testcase_17 AC 118 ms
7,572 KB
testcase_18 AC 42 ms
4,376 KB
testcase_19 AC 41 ms
4,784 KB
testcase_20 AC 95 ms
7,748 KB
testcase_21 AC 95 ms
7,500 KB
testcase_22 AC 98 ms
8,560 KB
testcase_23 AC 96 ms
8,564 KB
testcase_24 AC 77 ms
6,100 KB
testcase_25 AC 113 ms
7,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "testlib.h"

#include <vector>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

const int maxN = 100000;
const int maxQ = 100000;
const int maxT = 100000;

struct Query { int i, t; bool isstarting; };
vector<Query> queries;

int N, Q;
vector<int> playing; // for testing instructions duplicates
int playing_cnt = 0;
double X = 0.0;
vector<double> ansbuf;

int main() {
  registerValidation();

  cout << setprecision(10);

  N = inf.readInt(1,maxN);
  inf.readSpace();
  Q = inf.readInt(1,maxQ);
  inf.readEoln();

  playing.assign(N,0);
  ansbuf.assign(N,0.0);

  rep(q,Q) {
    int i = inf.readInt(1,N);
    inf.readSpace();
    int s = inf.readInt(0,maxT);
    inf.readSpace();
    int t = inf.readInt(0,maxT);
    inf.readEoln();
    ensure(s < t);
    i--;
    queries.push_back({ i,s,true });
    queries.push_back({ i,t,false });
  }

  inf.readEof();

  auto cmp_query_time = [](Query l, Query r)->bool {
    return make_pair(l.t,(l.isstarting?0:1)) < make_pair(r.t,(r.isstarting?0:1));
  };
  sort(queries.begin(), queries.end(), cmp_query_time);

  int T = 0;
  for (Query& q : queries) {
    if (playing_cnt != 0) X += double(q.t - T) / playing_cnt;
    if (q.isstarting) {
      ensure(playing[q.i] == 0); // instructions duplicate
      playing[q.i] = 1;
      ansbuf[q.i] -= X;
      playing_cnt++;
    }
    else {
      playing[q.i] = 0;
      ansbuf[q.i] += X;
      playing_cnt--;
    }
    T = q.t;
  }

  rep(i,N) cout << ansbuf[i] << "\n";

  return 0;
}
0