Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Created January 26, 2019 16:52
Show Gist options
  • Save tuankiet65/cd4a88271a0566e150d88390874500e5 to your computer and use it in GitHub Desktop.
Save tuankiet65/cd4a88271a0566e150d88390874500e5 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <iostream>
#include <vector>
int k;
std::vector<int> a;
int main() {
std::cin >> k;
for (int i = 0; i < k; ++i) {
int n;
std::cin >> n;
a.push_back(n);
}
std::cout << *std::max_element(a.begin(), a.end()) << std::endl;
return 0;
}
@huynhducduy
Copy link

#include <iostream>

int main() {
    
    int n,k,sum = 0;
	std::cin >> n;
	std::cin >> k;

	for (int i = 0; i < n; ++i) {
		int x;
		std::cin >> x;
		for (;x > k;) {
		    sum += x;
		    break;
		}
	}
	
	std::cout << sum << std::endl;
	return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment