Submission #00066


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ll n,l;
cin>>n>>l;
vector<pair<int,bool>> p(n);
int a,b;
for(int i=0;i<n;++i){
cin>>p[i].first>>p[i].second;
}
sort(p.begin(),p.end());
int sum=0;
for(int i=0;i<n;++i){
sum+=(p[i].first-(i+1))*(p[i].second==0 ? 1 : -1);
//cout<<p[i].first<<"\n"<<sum<<"\n";
}
int hold=max(sum,0);
//cout<<sum<<"\n";
int j=0;
for(int i=n-1;i>=0;--i){
sum-=(p[i].first-(i+1))*(p[i].second==0 ? 1 : -1);
//cout<<sum<<"\n";
sum+=(l-p[i].first-j)*(p[i].second==1 ? 1 : -1);
//cout<<p[i].first<<"\n"<<sum<<"\n";
hold=max(hold,sum);
j++;
}
cout<<hold<<"\n";
return 0;
}

ステータス

項目 データ
問題 0007 - 矢印
ユーザー名 雑種猫
投稿日時 2021-09-10 16:30:37
言語 C++17
状態 Compile Error
得点 0
ソースコード長 801 Byte
最大実行時間 -
最大メモリ使用量

コンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:6:5: error: ‘ll’ was not declared in this scope
     ll n,l;
     ^~
./Main.cpp:7:10: error: ‘n’ was not declared in this scope
     cin>>n>>l;
          ^
./Main.cpp:7:10: note: suggested alternative: ‘yn’
     cin>>n>>l;
          ^
          yn
./Main.cpp:7:13: error: ‘l’ was not declared in this scope
     cin>>n>>l;
             ^
./Main.cpp:19:23: error: no matching function for call to ‘max(long long int&, int)’
     int hold=max(sum,0);
                       ^
In file included from /usr/local/gcc-8.2.0/include/c++/8.2.0/bits/specfun.h:45,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/cmath:1892,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:41,
                 from ./Main.cpp:1:
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algobase.h:219:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
./Main.cpp:19:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
     int hold=max(sum,0);
                       ^
In file included from /usr/local/gcc-8.2.0/include/c++/8.2.0/bits/specfun.h:45,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/cmath:1892,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:41,
                 from ./Main.cpp:1:
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algobase.h:265:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
./Main.cpp:19:23: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long long int’ and ‘int’)
     int hold=max(sum,0);
                       ^
In file included from /usr/local/gcc-8.2.0/include/c++/8.2.0/algorithm:62,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:65,
                 from ./Main.cpp:1:
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algo.h:3462:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
     max(initializer_list<_Tp> __l)
     ^~~
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
./Main.cpp:19:23: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
     int hold=max(sum,0);
                       ^
In file included from /usr/local/gcc-8.2.0/include/c++/8.2.0/algorithm:62,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/x86_64-pc-linux-gnu/bits/stdc++.h:65,
                 from ./Main.cpp:1:
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algo.h:3468:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
./Main.cpp:19:23: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
     int hold=max(sum,0);
                       ^

セット

セット 得点 Cases

テストケース

ファイル名 状態 実行時間 メモリ使用量 #