Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Editor live
Comprimi invariate
Senza a capo
Layout
Diviso
Unificato
Livello di dettaglio
Intelligente
Parola
Carattere
Evidenziazione sintassi
Scegli sintassi
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
Untitled Diff
Creato
6 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
3 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
50 linee
Copia tutti
5 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
50 linee
Copia tutti
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace std;
Copia
Copiato
Copia
Copiato
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();
}
}
Copia
Copiato
Copia
Copiato
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);
Copia
Copiato
Copia
Copiato
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;
}
}
Diff salvati
Testo originale
Apri file
#include <bits/stdc++.h> using namespace std; typedef long long ull; struct cashier { int id, maxTime, cashierId; }; struct comp { bool operator() (cashier a, cashier b) { if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId; return a.maxTime > b.maxTime; } }; bool compV(cashier a, cashier b) { if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId; return a.maxTime < b.maxTime; } int main(int argc, const char * argv[]) { int n, cashierNum; cin >> n >> cashierNum; priority_queue<cashier, vector<cashier>, comp> line; vector<cashier> popLine; ull ret = 0; for (int i=0; i<n; i++) { int id, w; cin >> id >> w; if(i<cashierNum) { line.push({id, w, i+1}); continue; } line.push({id, w+line.top().maxTime, line.top().cashierId}); popLine.push_back(line.top()); line.pop(); } while (line.size()) { popLine.push_back(line.top()); line.pop(); } sort(popLine.begin(), popLine.end(), compV); for (int i=0; i<popLine.size(); i++) { ret += (ull)((i+1)*(ull)popLine[i].id); } cout << ret << "\n"; return 0; }
Testo modificato
Apri file
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; struct cashier { int id, maxTime, cashierId; }; struct comp { bool operator() (cashier a, cashier b) { if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId; return a.maxTime > b.maxTime; } }; bool compV(cashier a, cashier b) { if(a.maxTime==b.maxTime) return a.cashierId > b.cashierId; return a.maxTime < b.maxTime; } int main(int argc, const char * argv[]) { int n, cashierNum; cin >> n >> cashierNum; priority_queue<cashier, vector<cashier>, comp> line; vector<cashier> popLine; ull ret = 0; for (int i=0; i<n; i++) { int id, w; cin >> id >> w; if(i<cashierNum) { line.push({id, w, i+1}); continue; } line.push({id, w+line.top().maxTime, line.top().cashierId}); popLine.push_back(line.top()); line.pop(); } while (!line.empty()) { // 이 줄만 수정했습니다. popLine.push_back(line.top()); line.pop(); } sort(popLine.begin(), popLine.end(), compV); for (int i=0; i<n; i++) { ret += (ull)((i+1)*popLine[i].id); } cout << ret << "\n"; return 0; }
Trovare la differenza