版本比较
aaaaa
正文
增加 8 行删除 8 行
64 行未改动65666768697071727374757677787980816 行未改动8889909192939495969798991001011021031043 行未改动10810911011111211311411511611711864 行未改动int main() {ios_base::sync_with_stdio(false);cin.tie(NULL);int q;long long k;cin >> q >> k;vector<Event> events;vector<long long> answers(q, -1);int query_count = 0;for (int i = 0; i < q; i++) {int t;cin >> t;if (t == 1) {6 行未改动events.push_back({d, 2, 0, query_count});query_count++;}}// 排序:时间小的在前,时间相同则操作(1)在前,查询(2)在后sort(events.begin(), events.end(), [](const Event& e1, const Event& e2) {if (e1.time != e2.time) return e1.time < e2.time;return e1.type < e2.type; // 1 < 2});long long total_y = 0;for (const auto& e : events) {if (e.type == 1) {// 操作long long current_x = k * e.time - total_y;3 行未改动// 查询answers[e.idx] = total_y;}}for (int i = 0; i < query_count; i++) {cout << answers[i] << "\n";}return 0;}64 行未改动65666768697071727374757677787980816 行未改动8889909192939495969798991001011021031043 行未改动10810911011111211311411511611711864 行未改动int main() {ios_base::sync_with_stdio(false);cin.tie(NULL);int q;long long k;cin >> q >> k;vector<Event> events;vector<long long> answers(q, -1);int query_count = 0;for (int i = 0; i < q; i++) {int t;cin >> t;if (t == 1) {6 行未改动events.push_back({d, 2, 0, query_count});query_count++;}}// 排序:时间小的在前,时间相同则操作(1)在前,查询(2)在后sort(events.begin(), events.end(), [](const Event& e1, const Event& e2) {if (e1.time != e2.time) return e1.time < e2.time;return e1.type < e2.type; // 1 < 2});long long total_y = 0;for (const auto& e : events) {if (e.type == 1) {// 操作long long current_x = k * e.time - total_y;3 行未改动// 查询answers[e.idx] = total_y;}}for (int i = 0; i < query_count; i++) {cout << answers[i] << "\n";}return 0;}