287 words
1 minutes
【ABC325】B - World Meeting
問題
問題ページへのリンクはこちら
考え方
会議は1時間かかり、さらに各現地時間の9〜18時に収まる必要がある。
Xi時をスタートとして、入力された要素を全探索すれば良い。
X1〜Xnのそれぞれについて、Xi〜Xi+8までの範囲でWiを足していく。
もしXiが24以上なら、24で割ったあまりを求めて0〜余りに該当するXiがあればそれも含める(人数に加算する)。
コード
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#include "../../library/mylibrary.cpp"
int main() {
int n, t;
cin >> n;
vector<vector<int>> data(n, vector<int>(2));
vector<int> ans(n);
rep(i, 0, n) { cin >> data[i][0] >> data[i][1]; }
// print_vec2(data);
sort_vec2(data, 1);
// print_vec2(data);
rep(i, 0, data.size()) {
rep(j, 0, data.size()) {
t = data[i][1] + 8;
if (data[i][1] <= data[j][1] &&
data[j][1] <= t) { // Xi ~ Xi+8の範囲なら
ans[i] += data[j][0];
} else if (24 <= t) {
int p = t % 24; // 24以上の値だと、余りが代入される
if (data[j][1] <= p) {
ans[i] += data[j][0];
}
}
// cout << "~" << i << spa << j << el;
// print_vec(ans);
}
}
// cout << "---" << el;
// print_vec(ans);
sort(rall(ans));
cout << ans[0] << el;
}

