ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2033. Devices

WA #34
Posted by GerkON 30 Nov 2019 16:39
My code:

#include<iostream>
#include<map>
#include<string>
using namespace std;

#define DL 0 //Debug log

string SIB; //String input bufer
unsigned long CIB; //Cost input bufer

map<string, unsigned long>DC; //Devices cost
map<string, unsigned long>DR; //Devices repits

unsigned short RR; //Repits record
unsigned long RC; //Record cost

string O; //Output

int main() {
    for (unsigned short i = 0; i < 6; i++) {
        cin >> SIB;
        cin >> SIB;
        cin >> CIB;
        if (CIB > RC) RC = CIB;
        if(DC[SIB] == 0 || DC[SIB] > CIB) DC[SIB] = CIB;
        DR[SIB]++;
        if (DR[SIB] > RR) RR = DR[SIB];
    }

    if (DL) {
        cout << endl;
        cout << "Name repits cost:" << endl;
        for (auto i : DR) {
            cout << i.first << " " << i.second << " " << DC[i.first] << endl;
        }
        cout << endl;
    }

    for (auto i : DR) {
        if (i.second == RR) {
            if (DC[i.first] < RC) {
                RC = DC[i.first];
                O = i.first;
            }
        }
    }
    cout << O;
}

Give me plz some test

Edited by author 30.11.2019 17:00