#include "testlib.h" #include using namespace std; int readAns(InStream &stream, vector &prices, int size) { int revenue = stream.readInt(); vector pieces; int totalSize = 0, totalPrice = 0; while (!stream.seekEof()) { pieces.push_back(stream.readInt(1, size)); totalSize += pieces.back(); totalPrice += prices[pieces.back()]; } quitif(totalSize != size, _wa, "Pieces sizes dont add up to the given piece size"); quitif(totalPrice != revenue, _wa, "Pieces prices dont add up to the revenue given"); return revenue; } int main(int argc, char* argv[]) { setName("compare two signed int%d's", 8 * int(sizeof(int))); registerTestlibCmd(argc, argv); int n = inf.readInt(); vector prices(n + 1); for (int i = 1; i <= n; i++) { prices[i] = inf.readInt(); } int ja = readAns(ans, prices, n); int pa = readAns(ouf, prices, n); if (ja > pa) quitf(_wa, "Expected (%i) found (%i)", ja, pa); if (ja < pa) quitf(_fail, "Participant gave a better answer. PA - (%i), JA - (%i)", pa, ja); quitf(_ok, "OK"); }