|
|
вернуться в форум#include <iostream> #include <algorithm> using namespace std; int n; int a[30]; int main() { cin >> n; int i; for (i=0;i<n;i++) cin >> a[i]; sort(a,a+n); int ans=n; for (i=0;i<n-1;i++) if (a[i+1]-a[i]==1) { i++; ans--; } cout << ans << endl; cin >> n; } try this test: 4 1 1 2 2 correct answer is 2 I have the same answer, but i still have WA 6. Could you give some more tests? Try this test: 5 5 7 6 7 4 Answer is 3 Try this test: 5 5 7 6 7 4 Answer is 3 Why answer is 3 ??????????? все понял a=5 b=7 c=6 d=7 e=4 ------------- ______| __aeaeaeaea bcbcbcbcbcbcb ___ddddddd Accepted 0.001 141 КБ ))) Edited by author 02.08.2008 12:17 You considered the problem to be too simple... |
|
|