답안 #814503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
814503 2023-08-08T08:01:32 Z 반딧불(#10119) Arranging Tickets (JOI17_arranging_tickets) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
int ex[302], ey[302], ew[302];
int arr[302];
int ans = 1e9;

int main(){
    scanf("%d %d", &n, &k);
    for(int i=1; i<=k; i++){
        scanf("%d %d %d", &ex[i], &ey[i], &ew[i]);
    }

    while(1){
        for(int i=1; i<=n; i++) arr[i] = 0;
        for(int i=1; i<=k; i++) for(int j=ex[i]; j!=ey[i]; j=j%n+1) arr[j]++;

        int maxX = max_element(arr+1, arr+n+1) - arr;
        bool found = 0;
        for(int i=1; i<=k; i++){
            if((ex[i] <= maxX && maxX < ey[i]) || (ey[i] < ex[i] && (ex[i] <= maxX || maxX < ey[i]))){
                int MX = 0;
                for(int j=ey[i]; j!=ex[i]; j=j%n+1) MX = max(MX, arr[j]+1);
                if(MX < arr[maxX]){
                    swap(ex[i], ey[i]);
                    found = 1;
                    break;
                }
            }
        }
        if(!found) break;
    }

    ans = *max_element(arr+1, arr+n+1);

    printf("%d", ans);
}

Compilation message

arranging_tickets.cpp: In function 'int main()':
arranging_tickets.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
arranging_tickets.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d %d %d", &ex[i], &ey[i], &ew[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -