답안 #370780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
370780 2021-02-24T15:15:10 Z cpp219 이상한 기계 (APIO19_strange_device) C++14
65 / 100
551 ms 69344 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e6 + 3;
const ll inf = 1e9 + 7;
LL a[N];
ll n,A,B,q,total;
vector<LL> v;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>n>>A>>B; q = A/__gcd(B + 1,A); total = q * B;
    for (ll i = 1;i <= n;i++){
        cin>>a[i].fs>>a[i].sc;
        a[i].fs %= total; a[i].sc %= total;
        if (a[i].fs <= a[i].sc) v.push_back(a[i]);
        else{
            v.push_back({0,a[i].sc}); v.push_back({a[i].fs,total - 1});
        }
    }
    sort(v.begin(),v.end());
    ll mx = -inf,ans = 0;
    for (auto i : v){
        if (i.sc <= mx) continue;
        if (i.fs > mx) ans += i.sc - i.fs + 1;
        else ans += i.sc - mx;
        mx = max(mx,i.sc);
    }
    cout<<ans;
}

Compilation message

strange_device.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
strange_device.cpp:3: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
strange_device.cpp: In function 'int main()':
strange_device.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   23 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 6 ms 1260 KB Output is correct
3 Correct 6 ms 1260 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 5 ms 1260 KB Output is correct
17 Correct 51 ms 7396 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 375 ms 57020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 466 ms 46524 KB Output is correct
3 Correct 551 ms 69316 KB Output is correct
4 Correct 464 ms 69052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 466 ms 46524 KB Output is correct
3 Correct 551 ms 69316 KB Output is correct
4 Correct 464 ms 69052 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 467 ms 69052 KB Output is correct
7 Correct 492 ms 69124 KB Output is correct
8 Correct 475 ms 69184 KB Output is correct
9 Correct 517 ms 69060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 466 ms 46524 KB Output is correct
3 Correct 551 ms 69316 KB Output is correct
4 Correct 464 ms 69052 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 46 ms 7396 KB Output is correct
7 Correct 49 ms 7396 KB Output is correct
8 Correct 59 ms 7396 KB Output is correct
9 Correct 60 ms 7396 KB Output is correct
10 Correct 47 ms 7396 KB Output is correct
11 Correct 55 ms 7412 KB Output is correct
12 Correct 46 ms 7268 KB Output is correct
13 Correct 48 ms 7396 KB Output is correct
14 Correct 45 ms 7396 KB Output is correct
15 Correct 50 ms 7396 KB Output is correct
16 Correct 49 ms 7396 KB Output is correct
17 Correct 47 ms 7396 KB Output is correct
18 Correct 476 ms 69052 KB Output is correct
19 Correct 464 ms 69344 KB Output is correct
20 Correct 526 ms 69052 KB Output is correct
21 Correct 49 ms 7396 KB Output is correct
22 Correct 44 ms 7396 KB Output is correct
23 Correct 147 ms 23760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 53 ms 7396 KB Output is correct
3 Correct 51 ms 7396 KB Output is correct
4 Correct 542 ms 69052 KB Output is correct
5 Correct 50 ms 7396 KB Output is correct
6 Correct 48 ms 7396 KB Output is correct
7 Correct 49 ms 7396 KB Output is correct
8 Correct 51 ms 7396 KB Output is correct
9 Correct 50 ms 7396 KB Output is correct
10 Correct 61 ms 7396 KB Output is correct
11 Correct 51 ms 7396 KB Output is correct
12 Correct 44 ms 7396 KB Output is correct
13 Correct 49 ms 7396 KB Output is correct
14 Correct 520 ms 69080 KB Output is correct
15 Correct 50 ms 7396 KB Output is correct
16 Correct 504 ms 68972 KB Output is correct
17 Correct 461 ms 69072 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 6 ms 1260 KB Output is correct
3 Correct 6 ms 1260 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 5 ms 1260 KB Output is correct
17 Correct 51 ms 7396 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Incorrect 1 ms 364 KB Output isn't correct
21 Halted 0 ms 0 KB -