제출 #848047

#제출 시각아이디문제언어결과실행 시간메모리
848047eilouvreGym Badges (NOI22_gymbadges)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> struct gymPair { gymPair(int a, int b) { xp = a; maxLevel = b; } int xp; int maxLevel; }; bool compare_gyms(const gymPair& a, const gymPair& b) { int asum{ a.maxLevel + a.xp }; int bsum{ b.maxLevel + b.xp }; if (asum != bsum) { return (asum < bsum); } else { if (a.maxLevel != b.maxLevel) { return (a.maxLevel < b.maxLevel); } else { if (a.xp != b.xp) { return (a.xp < b.xp); } } } return true; } void simulate(std::vector<gymPair> gyms) { int xp{ 0 }; int badges{ 0 }; for (const gymPair& gym : gyms) { if (xp > gym.maxLevel) { continue; } else { xp += gym.xp; ++badges; } } std::cout << badges; } void make_ordered() { std::ios_base::sync_with_stdio(false); std::cin.tie(0) int n; std::cin >> n; std::vector<int> gymXP(n, 0); std::vector<int> gymMaxes(n, 0); for (int& i : gymXP) { std::cin >> i; } for (int& i : gymMaxes) { std::cin >> i; } std::vector<gymPair> gyms; for (size_t i = 0; i < n; ++i) { if (gymXP[i] == gymMaxes[i]) { continue; } gyms.push_back(gymPair(gymXP[i], gymMaxes[i])); } std::sort(gyms.begin(), gyms.end(), compare_gyms); return simulate(gyms); } int main() { make_ordered(); }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void make_ordered()':
Main.cpp:50:19: error: expected ';' before 'int'
   50 |    std::cin.tie(0)
      |                   ^
      |                   ;
   51 |  int n; std::cin >> n;
      |  ~~~               
Main.cpp:51:21: error: 'n' was not declared in this scope
   51 |  int n; std::cin >> n;
      |                     ^