Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
Untitled Diff
Créé
il y a 6 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
3 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
50 lignes
Copier tout
5 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
50 lignes
Copier tout
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using namespace std;
Copier
Copié
Copier
Copié
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();
}
}
Copier
Copié
Copier
Copié
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);
Copier
Copié
Copier
Copié
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érences enregistrées
Texte d'origine
Ouvrir un fichier
#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; }
Texte modifié
Ouvrir un fichier
#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; }
Trouver la différence