Submission #810705

#TimeUsernameProblemLanguageResultExecution timeMemory
810705Username4132Akcija (COCI21_akcija)C++14
10 / 110
138 ms16828 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; using ll = long long; using pil = pair<int, ll>; #define forn(i, n) for(int i=0; i<(int)n; ++i) #define PB push_back #define F first #define S second #define MP make_pair const int MAXN = 20; int n, k, we[MAXN], tim[MAXN], arr[MAXN]; vector<pil> ans; void solve(int mask){ int cnt=0; ll sum=0; forn(i, n) arr[i]=0; while(mask){ int x = __builtin_ctz(mask); mask^=(1<<x); ++cnt; sum+=we[x]; arr[tim[x]]++; } bool flag=true; forn(i, n-1) arr[i+1]+=arr[i]; forn(i, n) flag&=(arr[i]<=(i+1)); if(flag) ans.PB({cnt, sum}); } int main(){ scanf("%d %d", &n, &k); forn(i, n){ scanf("%d %d", &we[i], &tim[i]); --tim[i]; } forn(i, (1<<n)) solve(i); sort(ans.begin(), ans.end(), [](pil a, pil b){ return MP(-a.F, a.S) < MP(-b.F, b.S); }); forn(i, k) printf("%d %lld\n", ans[i].F, ans[i].S); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf("%d %d", &we[i], &tim[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...