CSES - Leirikisa 5 - Results
Submission details
Task:dobri
Sender:Hansuzu
Submission time:2016-08-02 15:20:22 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.06 sdetails
#2ACCEPTED0.06 sdetails
#3ACCEPTED0.06 sdetails
#4ACCEPTED0.05 sdetails
#5ACCEPTED0.06 sdetails
#6ACCEPTED0.06 sdetails
#7ACCEPTED0.05 sdetails
#8ACCEPTED0.05 sdetails
#9ACCEPTED0.05 sdetails
#10ACCEPTED0.06 sdetails
#11ACCEPTED0.22 sdetails
#12ACCEPTED0.23 sdetails
#13ACCEPTED0.23 sdetails

Code

#include <iostream>
#include <unordered_set>
using namespace std;
int N;

unordered_set<int> s2;

int x[5050];

int main(){
  cin >> N;
  int ans=0;
  for (int i=0; i<N; ++i){
    cin >> x[i];
    bool good=0;
    for (int j=0; j<i; ++j){
      if (s2.count(x[i]-x[j])){
	good=1;
	break;
      }
    }
    for (int j=0; j<=i; ++j){
      s2.insert(x[i]+x[j]);
    }
    ans+=good;
  }
  cout << ans << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
2
1 3

correct output
1

user output
1

Test 2

Verdict: ACCEPTED

input
6
1 2 3 5 7 10

correct output
4

user output
4

Test 3

Verdict: ACCEPTED

input
3
-1 2 0

correct output
1

user output
1

Test 4

Verdict: ACCEPTED

input
50
16291 48873 -24113 647 25407 7...

correct output
17

user output
17

Test 5

Verdict: ACCEPTED

input
50
28605 44105 100000 15416 10000...

correct output
6

user output
6

Test 6

Verdict: ACCEPTED

input
50
33946 -4739 33938 48034 100000...

correct output
5

user output
5

Test 7

Verdict: ACCEPTED

input
50
47168 -43373 45399 49194 6990 ...

correct output
21

user output
21

Test 8

Verdict: ACCEPTED

input
500
1 3 9 27 39 117 351 1053 1521 ...

correct output
445

user output
445

Test 9

Verdict: ACCEPTED

input
500
1 3 9 27 81 243 351 1053 3159 ...

correct output
448

user output
448

Test 10

Verdict: ACCEPTED

input
500
1 3 9 27 39 75 225 675 975 292...

correct output
444

user output
444

Test 11

Verdict: ACCEPTED

input
5000
1 3 9 27 39 117 351 507 1521 4...

correct output
4664

user output
4664

Test 12

Verdict: ACCEPTED

input
5000
1 3 9 27 39 75 225 339 1017 30...

correct output
4455

user output
4455

Test 13

Verdict: ACCEPTED

input
5000
1 3 9 13 25 47 85 157 289 531 ...

correct output
4436

user output
4436