답안 #288028

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288028 2020-09-01T08:00:00 Z 문홍윤(#5789) Skyscraper (JOI16_skyscraper) C++17
5 / 100
3 ms 256 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, l, ans;
int arr[10];

bool poss(vector<int> vc){
    int len=0;
    for(int i=1; i<vc.size(); i++){
        len+=abs(arr[vc[i]]-arr[vc[i-1]]);
    }
    return len<=l;
}

int main(){
    scanf("%d %d", &n, &l);
    if(n==1)return !printf("1");
    for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
    vector<int> vc;
    for(int i=1; i<=n; i++)vc.eb(i);
    if(poss(vc))ans++;
    while(next_permutation(all(vc))){
        if(poss(vc))ans++;
    }
    printf("%d", ans);
}

Compilation message

skyscraper.cpp: In function 'bool poss(std::vector<int>)':
skyscraper.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=1; i<vc.size(); i++){
      |                  ~^~~~~~~~~~
skyscraper.cpp: In function 'int main()':
skyscraper.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |     scanf("%d %d", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
skyscraper.cpp:32:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |     for(int i=1; i<=n; i++)scanf("%d", &arr[i]);
      |                            ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Incorrect 1 ms 256 KB Output isn't correct
12 Halted 0 ms 0 KB -