제출 #718284

#제출 시각아이디문제언어결과실행 시간메모리
718284vjudge1Table Tennis (info1cup20_tabletennis)C++17
87 / 100
3084 ms3240 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(x) x.begin(),x.end()
const int MOD = 1e9 + 7, SZ = 1e5 + 10, MX = 1e9;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, k;
    cin >> n >> k;
    int arr[n + k];
    for(int &i : arr)
        cin >> i;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k-i;j++){
            vector<int> ans;
            int l = i, r = n + k - j - 1, y = arr[i] + arr[n + k - j - 1];
            while(l < r){
                ll x = arr[l] + arr[r];
                if(ans.size() == n)
                    break;
                if(x == y){
                    ans.push_back(arr[l]);
                    ans.push_back(arr[r]);
                }
                if(x >= y)
                    r--;
                if(x <= y)
                    l++;
            }
            if(ans.size() == n){
                sort(all(ans));
                for(int x : ans)
                    cout << x << ' ';
                return 0;
            }
        }
    }
    return 0;
}
// https://www.youtube.com/watch?v=zL32whN6p0A&ab_channel=HeidiAdel-CartoonWorld

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

tabletennis.cpp: In function 'int main()':
tabletennis.cpp:20:31: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |                 if(ans.size() == n)
      |                    ~~~~~~~~~~~^~~~
tabletennis.cpp:31:27: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |             if(ans.size() == n){
      |                ~~~~~~~~~~~^~~~
#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...