Submission #340596

#TimeUsernameProblemLanguageResultExecution timeMemory
340596A_DPod starim krovovima (COCI20_psk)C++14
50 / 50
2 ms396 KiB
/* 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<ll,ll> a[N]; ll dp[N]; main() { //freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout); ll 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 (stderr)

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;
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...