답안 #844219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844219 2023-09-05T11:37:11 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
0 / 50
2 ms 600 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
#ifndef ONLINE_JUDGE
    #define OPEN freopen(".in", "r", stdin); \
                 freopen(".out", "w", stdout);
#else
    #define OPEN void(23);
#endif

void solve()
{
    int n; cin >> n;
    array <int, 3> arr[n];
    int sum = 0, cnt = 0;
    for(auto &[a, b, c] : arr) cin >> a >> b, sum += a, c = cnt++;

    sort(arr, arr + n, [&](array <int, 3> &a, array <int, 3> &b)
    {
        return a[1] > b[1];
    });

    vector <int> ans(n);
    int cev = n;
    for(int i = 1; i <= n; i++)
    {
        if(sum <= arr[i -1][1])
        {
            ans[arr[i -1][2]] = sum;
            cev--;
            break;
        }

        ans[arr[i -1][2]] = arr[i -1][1];
        sum -= arr[i -1][1];
        cev--;
    }

    for(int &i : ans) cout << i << " ";

    return;
}

int32_t main()
{
    OPEN;

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1; //cin >> t;
    while(t--)
    {
        solve();
    }
}

Compilation message

psk.cpp: In function 'int32_t main()':
psk.cpp:8:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     #define OPEN freopen(".in", "r", stdin); \
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~
psk.cpp:49:5: note: in expansion of macro 'OPEN'
   49 |     OPEN;
      |     ^~~~
psk.cpp:9:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |                  freopen(".out", "w", stdout);
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
psk.cpp:49:5: note: in expansion of macro 'OPEN'
   49 |     OPEN;
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 344 KB Unexpected end of file - int32 expected
2 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
3 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
4 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
5 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
6 Incorrect 2 ms 520 KB Unexpected end of file - int32 expected
7 Incorrect 2 ms 600 KB Unexpected end of file - int32 expected
8 Incorrect 1 ms 348 KB Unexpected end of file - int32 expected
9 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected
10 Incorrect 2 ms 348 KB Unexpected end of file - int32 expected