Create a gist now

Instantly share code, notes, and snippets.

@arukuka /ICPC2017A.cpp Secret
Created Jul 14, 2017

What would you like to do?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n, m;
while(cin >> n >> m, n) {
vector < int > v;
for(int i = 0; i < n; i++) {
int a; cin >> a;
v.push_back(a);
}
int maxi = -100000;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(i == j) continue;
if(v[i] + v[j] <= m) maxi = max(maxi, v[i] + v[j]);
}
}
if(maxi == -100000) {
cout << "NONE" << endl;
} else {
cout << maxi << endl;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment