답안 #271889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
271889 2020-08-18T07:55:33 Z 문홍윤(#5109) Archery (IOI09_archery) C++17
0 / 100
2000 ms 4216 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define svec(x) sort(x.begin(), x.end())
#define press(x) x.erase(unique(x.begin(), x.end()), x.end())
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
const LL llinf=2e18;
const int inf=1e9;

int n, r, arr[400010], p;
int s[400010], ans=inf, tmp[200010];

void operate(){
    for(int i=2; i<=n; i++)tmp[i]=min(s[2*i], s[2*i-1]);
    tmp[1]=max(s[1], s[2]);
    for(int i=2; i<n; i++){
        if(s[2*i-1]<s[2*i])s[2*i-1]=tmp[i+1];
        else s[2*i]=tmp[i+1];
    }
    if(s[2*n-1]<s[2*n])s[2*n-1]=tmp[1];
    else s[2*n]=tmp[1];
    if(s[1]>s[2])s[1]=tmp[2];
    else s[2]=tmp[2];
}

int simulate(int num){
    for(int i=1; i<num; i++)s[i]=arr[i];
    s[num]=p;
    for(int i=num; i<=2*n-1; i++)s[i+1]=arr[i];
    for(int i=1; i<=2*n; i++)operate();
    int nd=(r-2*n)%n;
    for(int i=1; i<=nd; i++)operate();
    for(int i=1; i<=2*n; i++){
        if(s[i]==p)return i;
    }
}

int main(){
    scanf("%d %d", &n, &r);
    LL sum=(LL)n*(2*n+1);
    scanf("%*d");
    for(int i=1; i<=2*n-1; i++){
        scanf("%d", &arr[i]);
        sum-=(LL)arr[i];
    }
    p=(int)sum;
    for(int i=1; i<=2*n; i++){
        ans=min(ans, simulate(i));
    }
    printf("%d", ans);
}

Compilation message

archery.cpp: In function 'int simulate(int)':
archery.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
archery.cpp: In function 'int main()':
archery.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   47 |     scanf("%d %d", &n, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~
archery.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   49 |     scanf("%*d");
      |     ~~~~~^~~~~~~
archery.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%d", &arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Execution timed out 2047 ms 384 KB Time limit exceeded
3 Incorrect 12 ms 384 KB Output isn't correct
4 Execution timed out 2056 ms 384 KB Time limit exceeded
5 Incorrect 1 ms 384 KB Output isn't correct
6 Incorrect 82 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Output isn't correct
2 Incorrect 131 ms 384 KB Output isn't correct
3 Execution timed out 2062 ms 384 KB Time limit exceeded
4 Execution timed out 2068 ms 640 KB Time limit exceeded
5 Execution timed out 2073 ms 3576 KB Time limit exceeded
6 Incorrect 99 ms 384 KB Output isn't correct
7 Execution timed out 2076 ms 384 KB Time limit exceeded
8 Execution timed out 2040 ms 640 KB Time limit exceeded
9 Execution timed out 2077 ms 768 KB Time limit exceeded
10 Execution timed out 2089 ms 384 KB Time limit exceeded
11 Execution timed out 2092 ms 768 KB Time limit exceeded
12 Execution timed out 2092 ms 384 KB Time limit exceeded
13 Execution timed out 2078 ms 2680 KB Time limit exceeded
14 Execution timed out 2088 ms 384 KB Time limit exceeded
15 Execution timed out 2085 ms 896 KB Time limit exceeded
16 Incorrect 102 ms 384 KB Output isn't correct
17 Execution timed out 2094 ms 384 KB Time limit exceeded
18 Execution timed out 2084 ms 384 KB Time limit exceeded
19 Execution timed out 2073 ms 384 KB Time limit exceeded
20 Execution timed out 2069 ms 384 KB Time limit exceeded
21 Execution timed out 2066 ms 768 KB Time limit exceeded
22 Execution timed out 2077 ms 896 KB Time limit exceeded
23 Execution timed out 2072 ms 3832 KB Time limit exceeded
24 Incorrect 100 ms 384 KB Output isn't correct
25 Execution timed out 2095 ms 384 KB Time limit exceeded
26 Execution timed out 2059 ms 384 KB Time limit exceeded
27 Execution timed out 2052 ms 768 KB Time limit exceeded
28 Execution timed out 2041 ms 2776 KB Time limit exceeded
29 Execution timed out 2075 ms 384 KB Time limit exceeded
30 Execution timed out 2069 ms 384 KB Time limit exceeded
31 Execution timed out 2083 ms 768 KB Time limit exceeded
32 Execution timed out 2089 ms 3704 KB Time limit exceeded
33 Incorrect 114 ms 384 KB Output isn't correct
34 Incorrect 87 ms 384 KB Output isn't correct
35 Execution timed out 2060 ms 384 KB Time limit exceeded
36 Execution timed out 2064 ms 384 KB Time limit exceeded
37 Execution timed out 2073 ms 640 KB Time limit exceeded
38 Execution timed out 2065 ms 768 KB Time limit exceeded
39 Incorrect 83 ms 504 KB Output isn't correct
40 Execution timed out 2083 ms 384 KB Time limit exceeded
41 Execution timed out 2059 ms 384 KB Time limit exceeded
42 Execution timed out 2087 ms 384 KB Time limit exceeded
43 Execution timed out 2083 ms 384 KB Time limit exceeded
44 Execution timed out 2094 ms 512 KB Time limit exceeded
45 Execution timed out 2087 ms 768 KB Time limit exceeded
46 Execution timed out 2063 ms 768 KB Time limit exceeded
47 Execution timed out 2080 ms 4216 KB Time limit exceeded