제출 #686601

#제출 시각아이디문제언어결과실행 시간메모리
686601alexdumitruTable Tennis (info1cup20_tabletennis)C++14
87 / 100
3077 ms4680 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int NMAX = 150000; int n, k; int a[NMAX + 401]; vector<int> v1, v2; bool works(int sum) { v1.clear(); v2.clear(); int cnt = 0; int j = n + k; for(int i = 1; i <= n + k; i++) { for(; j >= 1 && a[i] + a[j] > sum; j--); if(i >= j) break; if(a[i] + a[j] == sum) { cnt++; v1.push_back(a[i]); v2.push_back(a[j]); if(cnt == n / 2) break; } } return cnt == n / 2; } void solve() { cin >> n >> k; for(int i = 1; i <= n + k; i++) cin >> a[i]; sort(a + 1, a + n + k + 1); bool ok = false; for(int i = 1; i <= k + 1 && ok == false; i++) for(int j = n; j <= n + k && ok == false; j++) if(works(a[i] + a[j])) ok = true; for(int i = 0; i < n / 2; i++) cout << v1[i] << ' '; for(int i = n / 2 - 1; i >= 0; i--) cout << v2[i] << ' '; cout << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.cpp: In function 'void solve()':
tabletennis.cpp:41:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   41 |     for(int i = 1; i <= n + k; i++)
      |     ^~~
tabletennis.cpp:43:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   43 |   sort(a + 1, a + n + k + 1);
      |   ^~~~
#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...