제출 #1001771

#제출 시각아이디문제언어결과실행 시간메모리
1001771daffuwuTable Tennis (info1cup20_tabletennis)C++14
20 / 100
34 ms6804 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long n, k, a[1500069]; vector<long long> ans; vector<long long> slv(long long sm) { long long i, l, r; vector<long long> ret; for (l=1, r=n+k; l<r; l++, r--) { for (; l<r && a[l]+a[r]>sm; r--); for (; l<r && a[l]+a[r]<sm; l++); if (l == r) break; ret.push_back(l); ret.push_back(r); } sort(ret.begin(), ret.end()); long long sz = ret.size(); long long m = (sz-n)/2; //hapus m kiri dan m kanan reverse(ret.begin(), ret.end()); for (i=1; i<=m; i++) ret.pop_back(); reverse(ret.begin(), ret.end()); for (i=1; i<=m; i++) ret.pop_back(); return ret; } int main() { long long i; scanf("%lld%lld", &n, &k); for (i=1; i<=n+k; i++) { scanf("%lld", a+i); } ans = slv(a[1]+a[n+k]); if (ans.size()<n) { ans = slv(a[1]+a[n+k-1]); if (ans.size()<n) ans = slv(a[2]+a[n+k]); } for (auto x:ans) printf("%lld ", a[x]); printf("\n"); }

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:42:19: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   42 |     if (ans.size()<n)
      |         ~~~~~~~~~~^~
tabletennis.cpp:45:23: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   45 |         if (ans.size()<n) ans = slv(a[2]+a[n+k]);
      |             ~~~~~~~~~~^~
tabletennis.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%lld%lld", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
tabletennis.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |         scanf("%lld", a+i);
      |         ~~~~~^~~~~~~~~~~~~
#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...