Submission #339953

#TimeUsernameProblemLanguageResultExecution timeMemory
339953HazemPod starim krovovima (COCI20_psk)C++14
50 / 50
3 ms384 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 2e5 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; vector<pair<pair<int,int>,int>>vec; int ans[N]; int main() { //freopen("out.txt","w",stdout); int n; scanf("%d",&n); for(int i=1;i<=n;i++){ int a,b; scanf("%d%d",&a,&b); vec.push_back({{b,a},i}); } sort(vec.begin(),vec.end()); for(int i=0;i<vec.size();i++) for(int j=vec.size()-1;j>i;j--){ int mn = min(vec[i].F.S,vec[j].F.F-vec[j].F.S); vec[i].F.S -= mn,vec[j].F.S += mn; } int cnt = 0; for(auto x:vec) ans[x.S] = x.F.S,cnt += !ans[x.S]; printf("%d\n",cnt); for(int i=1;i<=n;i++) printf("%d ",ans[i]); }

Compilation message (stderr)

psk.cpp: In function 'int main()':
psk.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i=0;i<vec.size();i++)
      |                 ~^~~~~~~~~~~
psk.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
psk.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |         scanf("%d%d",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...