Submission #783243

#TimeUsernameProblemLanguageResultExecution timeMemory
783243PanosPaskPairs (IOI07_pairs)C++14
30 / 100
17 ms1580 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int B, N, D, M; ll ans = 0; void case1(void) { vector<int> animals(N); for (int i = 0; i < N; i++) scanf("%d", &animals[i]); sort(animals.begin(), animals.end()); int l = 0; for (int r = 0; r < N; r++) { while (l < N && animals[r] - animals[l] > D) { l++; } ans += r - l; } printf("%lld\n", ans); } void case2(void) { printf("-1\n"); } void case3(void) { printf("-1\n"); } int main(void) { scanf("%d %d %d %d", &B, &N, &D, &M); if (B == 1) case1(); else if (B == 2) case2(); else case3(); return 0; }

Compilation message (stderr)

pairs.cpp: In function 'void case1()':
pairs.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d", &animals[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
pairs.cpp: In function 'int main()':
pairs.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d %d %d %d", &B, &N, &D, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...