제출 #548969

#제출 시각아이디문제언어결과실행 시간메모리
548969LucaDantasArranging Tickets (JOI17_arranging_tickets)C++17
10 / 100
137 ms340 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 22; struct Itv { int l, r, qtd; // subtasks 1-4 qtd == 1 so I can ignore it for what I'm going to code } itv[maxn]; int a[maxn]; // quantos caras precisam passar por cada pos int check(int mask, int n) { memset(a, 0, sizeof a); for(int i = 0; i < n; i++) { if(mask & (1 << i)) a[itv[i].l]++, a[itv[i].r]--; else a[itv[i].r]++, a[1]++, a[itv[i].l]--; } int ans = 0; for(int i = 1; i < maxn; i++) a[i] += a[i-1], ans = max(ans, a[i]); return ans; } int main() { int sz, n; scanf("%d %d", &sz, &n); for(int i = 0; i < n; i++) { scanf("%d %d %d", &itv[i].l, &itv[i].r, &itv[i].qtd); if(itv[i].l > itv[i].r) swap(itv[i].l, itv[i].r); } int ans = n; for(int mask = 0; mask < (1 << n); mask++) ans = min(ans, check(mask, n)); printf("%d\n", ans); }

컴파일 시 표준 에러 (stderr) 메시지

arranging_tickets.cpp: In function 'int main()':
arranging_tickets.cpp:27:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  int sz, n; scanf("%d %d", &sz, &n);
      |             ~~~~~^~~~~~~~~~~~~~~~~~
arranging_tickets.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d %d %d", &itv[i].l, &itv[i].r, &itv[i].qtd);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...