답안 #340594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340594 2020-12-28T00:16:04 Z A_D Pod starim krovovima (COCI20_psk) C++14
40 / 50
2 ms 364 KB
/*
ID: antwand1
TASK: barn1
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define du long double
#define F first
#define S second
using namespace std;
const int N=1e3+1;
pair<int,int> a[N];
int dp[N];
main()
{
    //freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout);
    int n,sum=0,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        int b;
        cin>>b;
        sum+=b;
        cin>>a[i].F;
        a[i].S=i;
    }
    sort(a+1,a+n+1);
    reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        int g=min(sum,a[i].F);
        sum-=g;
        dp[a[i].S]=g;
    }
    for(int i=1;i<=n;i++)
        if(dp[i]==0)ans++;
    cout<<ans<<endl;
    for(int i=1;i<=n;i++)cout<<dp[i]<<" ";cout<<endl;
}

Compilation message

psk.cpp:15:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main()
      |      ^
psk.cpp: In function 'int main()':
psk.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for(int i=1;i<=n;i++)cout<<dp[i]<<" ";cout<<endl;
      |     ^~~
psk.cpp:37:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |     for(int i=1;i<=n;i++)cout<<dp[i]<<" ";cout<<endl;
      |                                           ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Incorrect 2 ms 364 KB Output isn't correct