Untitled Diff

Created Diff never expires
3 removals
50 lines
4 additions
50 lines
#include <bits/stdc++.h>
#include <bits/stdc++.h>


using namespace std;
using namespace std;


typedef long long ull;
typedef unsigned long long ull;


struct cashier {
struct cashier {
int id, maxTime, cashierId;
int id, maxTime, cashierId;
};
};


struct comp {
struct comp {
bool operator() (cashier a, cashier b) {
bool operator() (cashier a, cashier b) {
if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId;
if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId;
return a.maxTime > b.maxTime;
return a.maxTime > b.maxTime;
}
}
};
};


bool compV(cashier a, cashier b) {
bool compV(cashier a, cashier b) {
if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId;
if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId;
return a.maxTime < b.maxTime;
return a.maxTime < b.maxTime;
}
}


int main(int argc, const char * argv[]) {
int main(int argc, const char * argv[]) {
int n, cashierNum;
int n, cashierNum;
cin >> n >> cashierNum;
cin >> n >> cashierNum;
priority_queue<cashier, vector<cashier>, comp> line;
priority_queue<cashier, vector<cashier>, comp> line;
vector<cashier> popLine;
vector<cashier> popLine;
ull ret = 0;
ull ret = 0;
for (int i=0; i<n; i++) {
for (int i=0; i<n; i++) {
int id, w;
int id, w;
cin >> id >> w;
cin >> id >> w;
if(i<cashierNum) {
if(i<cashierNum) {
line.push({id, w, i+1});
line.push({id, w, i+1});
continue;
continue;
}
}
line.push({id, w+line.top().maxTime, line.top().cashierId});
line.push({id, w+line.top().maxTime, line.top().cashierId});
popLine.push_back(line.top());
popLine.push_back(line.top());
line.pop();
line.pop();
}
}
while (line.size()) {
while (!line.empty()) { // 이 줄만 수정했습니다.
popLine.push_back(line.top());
popLine.push_back(line.top());
line.pop();
line.pop();
}
}
sort(popLine.begin(), popLine.end(), compV);
sort(popLine.begin(), popLine.end(), compV);
for (int i=0; i<popLine.size(); i++) {
for (int i=0; i<n; i++) {
ret += (ull)((i+1)*(ull)popLine[i].id);
ret += (ull)((i+1)*popLine[i].id);
}
}
cout << ret << "\n";
cout << ret << "\n";
return 0;
return 0;
}
}