Submission #557479

# Submission time Handle Problem Language Result Execution time Memory
557479 2022-05-05T11:03:24 Z new_acc Akcija (COCI21_akcija) C++14
90 / 110
518 ms 524288 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=2e3+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
vl dp[N][N];
pair<int,int> t[N];
vl comb(vl a,vl b){
    int w1=0,w2=0;
    vl res;
    while(w1<a.size() and w2<b.size()){
        if(a[w1]<b[w2]) res.push_back(a[w1]),w1++;
        else res.push_back(b[w2]),w2++;
    }
    for(int i=w1;i<a.size();i++) res.push_back(a[i]);
    for(int i=w2;i<b.size();i++) res.push_back(b[i]);
    return res;
}
void solve(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>t[i].fi>>t[i].se;
    sort(t+1,t+1+n,[](pair<int,int> a,pair<int,int> b){
        return a.se<b.se;
    });
    dp[0][0].push_back(0);
    for(int i=1;i<=n;i++){
        int aktsum=0;
        for(int j=max(0,t[i].se-i);j<=t[i].se;j++){
            if(j-(t[i].se-t[i-1].se)+1<0) continue;
            if(j-(t[i].se-t[i-1].se)<0){
                dp[i][j]=dp[i-1][j-(t[i].se-t[i-1].se)+1];
                for(auto &u:dp[i][j]) u+=(ll)t[i].fi;
            }else{
                vl pom=dp[i-1][j-(t[i].se-t[i-1].se)+1];
                for(auto &u:pom) u+=(ll)t[i].fi;
                dp[i][j]=comb(dp[i-1][j-(t[i].se-t[i-1].se)],pom);
            }
            aktsum+=dp[i][j].size();
            while(dp[i][j].size()>k) dp[i][j].pop_back(),aktsum--;
        }
    }
    int xd=0;
    for(int i=max(0,t[n].se-n);i<=t[n].se;i++){
        for(auto u:dp[n][i]){
            if(xd==k) break;
            cout<<t[n].se-i<<" "<<u<<"\n";
            xd++;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}

Compilation message

Main.cpp: In function 'vl comb(vl, vl)':
Main.cpp:25:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     while(w1<a.size() and w2<b.size()){
      |           ~~^~~~~~~~~
Main.cpp:25:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     while(w1<a.size() and w2<b.size()){
      |                           ~~^~~~~~~~~
Main.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=w1;i<a.size();i++) res.push_back(a[i]);
      |                  ~^~~~~~~~~
Main.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=w2;i<b.size();i++) res.push_back(b[i]);
      |                  ~^~~~~~~~~
Main.cpp: In function 'void solve()':
Main.cpp:54:34: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |             while(dp[i][j].size()>k) dp[i][j].pop_back(),aktsum--;
      |                   ~~~~~~~~~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 332 ms 152108 KB Output is correct
2 Correct 340 ms 155964 KB Output is correct
3 Correct 304 ms 145692 KB Output is correct
4 Correct 299 ms 146596 KB Output is correct
5 Correct 346 ms 155000 KB Output is correct
6 Correct 57 ms 95264 KB Output is correct
7 Correct 49 ms 95572 KB Output is correct
8 Correct 47 ms 95432 KB Output is correct
9 Correct 61 ms 96436 KB Output is correct
10 Correct 127 ms 108620 KB Output is correct
11 Correct 49 ms 95092 KB Output is correct
12 Correct 51 ms 95180 KB Output is correct
13 Correct 51 ms 95232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 332 ms 152108 KB Output is correct
2 Correct 340 ms 155964 KB Output is correct
3 Correct 304 ms 145692 KB Output is correct
4 Correct 299 ms 146596 KB Output is correct
5 Correct 346 ms 155000 KB Output is correct
6 Correct 57 ms 95264 KB Output is correct
7 Correct 49 ms 95572 KB Output is correct
8 Correct 47 ms 95432 KB Output is correct
9 Correct 61 ms 96436 KB Output is correct
10 Correct 127 ms 108620 KB Output is correct
11 Correct 49 ms 95092 KB Output is correct
12 Correct 51 ms 95180 KB Output is correct
13 Correct 51 ms 95232 KB Output is correct
14 Correct 319 ms 152140 KB Output is correct
15 Correct 356 ms 156016 KB Output is correct
16 Correct 290 ms 145628 KB Output is correct
17 Correct 293 ms 146404 KB Output is correct
18 Correct 346 ms 154936 KB Output is correct
19 Correct 48 ms 95208 KB Output is correct
20 Correct 48 ms 95576 KB Output is correct
21 Correct 56 ms 95336 KB Output is correct
22 Correct 51 ms 96496 KB Output is correct
23 Correct 143 ms 108576 KB Output is correct
24 Correct 49 ms 95156 KB Output is correct
25 Correct 46 ms 95188 KB Output is correct
26 Correct 45 ms 95180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 180640 KB Output is correct
2 Correct 392 ms 186344 KB Output is correct
3 Correct 400 ms 170852 KB Output is correct
4 Correct 342 ms 172008 KB Output is correct
5 Correct 416 ms 184900 KB Output is correct
6 Correct 46 ms 95308 KB Output is correct
7 Correct 49 ms 95768 KB Output is correct
8 Correct 50 ms 95468 KB Output is correct
9 Correct 54 ms 97052 KB Output is correct
10 Correct 129 ms 115308 KB Output is correct
11 Correct 46 ms 95180 KB Output is correct
12 Correct 44 ms 95172 KB Output is correct
13 Correct 49 ms 95180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 97228 KB Output is correct
2 Correct 51 ms 97388 KB Output is correct
3 Correct 47 ms 96716 KB Output is correct
4 Correct 47 ms 96348 KB Output is correct
5 Correct 48 ms 97416 KB Output is correct
6 Correct 48 ms 95180 KB Output is correct
7 Correct 52 ms 95740 KB Output is correct
8 Correct 47 ms 95312 KB Output is correct
9 Correct 46 ms 95308 KB Output is correct
10 Correct 51 ms 95080 KB Output is correct
11 Correct 48 ms 95144 KB Output is correct
12 Correct 56 ms 95092 KB Output is correct
13 Correct 50 ms 96584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 104052 KB Output is correct
2 Correct 53 ms 103848 KB Output is correct
3 Correct 52 ms 102476 KB Output is correct
4 Correct 52 ms 102344 KB Output is correct
5 Correct 53 ms 103648 KB Output is correct
6 Correct 54 ms 95236 KB Output is correct
7 Correct 48 ms 95952 KB Output is correct
8 Correct 44 ms 95564 KB Output is correct
9 Correct 47 ms 95952 KB Output is correct
10 Correct 51 ms 97504 KB Output is correct
11 Correct 50 ms 95128 KB Output is correct
12 Correct 47 ms 95068 KB Output is correct
13 Correct 49 ms 96840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 332 ms 152108 KB Output is correct
2 Correct 340 ms 155964 KB Output is correct
3 Correct 304 ms 145692 KB Output is correct
4 Correct 299 ms 146596 KB Output is correct
5 Correct 346 ms 155000 KB Output is correct
6 Correct 57 ms 95264 KB Output is correct
7 Correct 49 ms 95572 KB Output is correct
8 Correct 47 ms 95432 KB Output is correct
9 Correct 61 ms 96436 KB Output is correct
10 Correct 127 ms 108620 KB Output is correct
11 Correct 49 ms 95092 KB Output is correct
12 Correct 51 ms 95180 KB Output is correct
13 Correct 51 ms 95232 KB Output is correct
14 Correct 319 ms 152140 KB Output is correct
15 Correct 356 ms 156016 KB Output is correct
16 Correct 290 ms 145628 KB Output is correct
17 Correct 293 ms 146404 KB Output is correct
18 Correct 346 ms 154936 KB Output is correct
19 Correct 48 ms 95208 KB Output is correct
20 Correct 48 ms 95576 KB Output is correct
21 Correct 56 ms 95336 KB Output is correct
22 Correct 51 ms 96496 KB Output is correct
23 Correct 143 ms 108576 KB Output is correct
24 Correct 49 ms 95156 KB Output is correct
25 Correct 46 ms 95188 KB Output is correct
26 Correct 45 ms 95180 KB Output is correct
27 Correct 411 ms 180640 KB Output is correct
28 Correct 392 ms 186344 KB Output is correct
29 Correct 400 ms 170852 KB Output is correct
30 Correct 342 ms 172008 KB Output is correct
31 Correct 416 ms 184900 KB Output is correct
32 Correct 46 ms 95308 KB Output is correct
33 Correct 49 ms 95768 KB Output is correct
34 Correct 50 ms 95468 KB Output is correct
35 Correct 54 ms 97052 KB Output is correct
36 Correct 129 ms 115308 KB Output is correct
37 Correct 46 ms 95180 KB Output is correct
38 Correct 44 ms 95172 KB Output is correct
39 Correct 49 ms 95180 KB Output is correct
40 Correct 51 ms 97228 KB Output is correct
41 Correct 51 ms 97388 KB Output is correct
42 Correct 47 ms 96716 KB Output is correct
43 Correct 47 ms 96348 KB Output is correct
44 Correct 48 ms 97416 KB Output is correct
45 Correct 48 ms 95180 KB Output is correct
46 Correct 52 ms 95740 KB Output is correct
47 Correct 47 ms 95312 KB Output is correct
48 Correct 46 ms 95308 KB Output is correct
49 Correct 51 ms 95080 KB Output is correct
50 Correct 48 ms 95144 KB Output is correct
51 Correct 56 ms 95092 KB Output is correct
52 Correct 50 ms 96584 KB Output is correct
53 Correct 56 ms 104052 KB Output is correct
54 Correct 53 ms 103848 KB Output is correct
55 Correct 52 ms 102476 KB Output is correct
56 Correct 52 ms 102344 KB Output is correct
57 Correct 53 ms 103648 KB Output is correct
58 Correct 54 ms 95236 KB Output is correct
59 Correct 48 ms 95952 KB Output is correct
60 Correct 44 ms 95564 KB Output is correct
61 Correct 47 ms 95952 KB Output is correct
62 Correct 51 ms 97504 KB Output is correct
63 Correct 50 ms 95128 KB Output is correct
64 Correct 47 ms 95068 KB Output is correct
65 Correct 49 ms 96840 KB Output is correct
66 Runtime error 518 ms 524288 KB Execution killed with signal 9
67 Halted 0 ms 0 KB -