結果

問題 No.2462 七人カノン
ユーザー 👑 NachiaNachia
提出日時 2021-05-09 02:38:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,432 bytes
コンパイル時間 5,891 ms
コンパイル使用メモリ 221,984 KB
実行使用メモリ 8,500 KB
最終ジャッジ日時 2023-09-08 20:50:17
合計ジャッジ時間 13,221 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 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,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 91 ms
7,248 KB
testcase_14 AC 97 ms
8,500 KB
testcase_15 AC 92 ms
7,416 KB
testcase_16 AC 104 ms
7,496 KB
testcase_17 AC 103 ms
8,436 KB
testcase_18 AC 42 ms
4,768 KB
testcase_19 AC 42 ms
4,380 KB
testcase_20 AC 90 ms
7,580 KB
testcase_21 AC 90 ms
8,460 KB
testcase_22 AC 94 ms
7,580 KB
testcase_23 AC 90 ms
8,312 KB
testcase_24 AC 74 ms
6,024 KB
testcase_25 AC 106 ms
7,568 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 l.t < r.t; };
	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