結果
| 問題 |
No.5004 Room Assignment
|
| コンテスト | |
| ユーザー |
fky_
|
| 提出日時 | 2021-12-06 03:34:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 135 ms / 5,000 ms |
| コード長 | 1,289 bytes |
| コンパイル時間 | 1,821 ms |
| 実行使用メモリ | 22,380 KB |
| スコア | 137,178,766 |
| 平均クエリ数 | 7642.56 |
| 最終ジャッジ日時 | 2021-12-06 03:34:51 |
| 合計ジャッジ時間 | 20,405 ms |
|
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
| 純コード判定しない問題か言語 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 100 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define RFOR(i, a, b) for (int i = a; i >= (b); i--)
#define range(a) a.begin(), a.end()
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
using P = pair<int, int>;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
int main(void){
ios::sync_with_stdio(0);
cin.tie(0);
int T, R;
cin >> T >> R;
vector<priority_queue<int, vector<int>, greater<int>>> que(20);
vector<int> size(20, 0);
int cnt = 1;
FOR(t,0,T){
int N;
cin >> N;
FOR(i,0,N){
int s;
cin >> s;
if(s == 100) s--;
que[s / 5].push(cnt++);
}
vector<P> ans;
FOR(q,0,20){
while((int)que[q].size() >= 2){
int a = que[q].top();
que[q].pop();
int b = que[q].top();
que[q].pop();
ans.push_back({a, b});
size[q] += 2;
if(size[q] == 4){
size[q] = 0;
}else{
que[q].push(a);
--size[q];
}
}
}
cout << ans.size() << endl;
for(auto p: ans){
cout << p.first << " " << p.second << endl;
}
}
return 0;
}
fky_