Submission #565061

#TimeUsernameProblemLanguageResultExecution timeMemory
565061dantoh000Arranging Tickets (JOI17_arranging_tickets)C++14
10 / 100
231 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[25], b[25], c[25];
int x[25];
int main(){
    scanf("%d%d",&n,&m);
    for (int i = 0; i < m; i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        if (a[i] > b[i]) swap(a[i],b[i]);
    }
    int ans = m;
    for (int mask = 0; mask < (1<<m); mask++){
        for (int i = 1; i <= n; i++){
            x[i] = 0;
        }
        int ct = 0;
        for (int i = 0; i < m; i++){
            if ((mask>>i)&1){
                for (int j = a[i]; j < b[i]; j++){
                    x[j]++;
                }
            }
            else{
                ct++;
                for (int j = a[i]; j < b[i]; j++){
                    x[j]--;
                }
            }
        }
        int mx = 0;
        for (int i = 1; i <= n; i++){
            mx = max(mx, x[i]);
        }
        ans = min(ans,mx+ct);
    }
    printf("%d\n",ans);


}

Compilation message (stderr)

arranging_tickets.cpp: In function 'int main()':
arranging_tickets.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
arranging_tickets.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d%d%d",&a[i],&b[i],&c[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...