# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
628660 | 2022-08-13T15:03:39 Z | Iwanttobreakfree | Fancy Fence (CEOI20_fancyfence) | C++17 | 128 ms | 12208 KB |
#include <iostream> #include <vector> #include <map> using namespace std; const int mod=1e9+7; #define int long long signed main(){ int n; cin>>n; vector<int> v(n),h(n); map<int,int> mp; for(int& i:h)cin>>i; for(int& i:v)cin>>i; for(int i=0;i<n;i++){ mp[h[i]]=(mp[h[i]]+v[i])%mod; } vector<pair<int,int>> comp; for(auto x:mp)comp.push_back(x); for(int i=comp.size()-1;i>0;i--)comp[i-1].second=(comp[i-1].second+comp[i].second)%mod; int ans=0; for(int i=0;i<comp.size();i++){ pair<int,int> x=comp[i]; //cout<<(1ll*x.first*(x.first+1)/2)<<' '<<(1ll*x.second*(x.second+1)/2)<<'\n'; ans+=(((x.first*(x.first+1)/2)%mod)*((x.second*(x.second+1)/2)%mod))%mod; ans%=mod; if(i){ pair<int,int> y=comp[i-1]; ans-=(((y.first*(y.first+1)/2)%mod)*((x.second*(x.second+1)/2)%mod))%mod; if(ans<0)ans=((ans%mod)+mod)%mod; } } //cout<<(((1ll*(mod-7)*(mod-6)/2)%mod)*((1ll*(mod-7)*(mod-6)/2)%mod))%mod<<' '; cout<<ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | 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 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 316 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 7 ms | 596 KB | Output is correct |
3 | Correct | 38 ms | 2096 KB | Output is correct |
4 | Correct | 74 ms | 3780 KB | Output is correct |
5 | Correct | 78 ms | 3904 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 8 ms | 596 KB | Output is correct |
4 | Correct | 38 ms | 1952 KB | Output is correct |
5 | Correct | 80 ms | 3772 KB | Output is correct |
6 | Correct | 76 ms | 3896 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 10 ms | 1620 KB | Output is correct |
9 | Correct | 49 ms | 3916 KB | Output is correct |
10 | Correct | 128 ms | 12076 KB | Output is correct |
11 | Correct | 110 ms | 12208 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 340 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |